簡體   English   中英

為什么在R中繪制高密度點曲線的output不平滑?

[英]Why is the output of plotting a curve of high-density points in R not smooth?

基本 R 中的這一事實讓我感到困惑。

我正在繪制我的數據的計數直方圖,然后覆蓋我認為是數據基礎的伽馬分布的形狀。 伽瑪分布上的點是使用dgamma生成並使用curve繪制的。 無論我使用多少點來生成曲線,output 仍然看起來像素化。 有誰知道為什么以及是否有可能獲得平滑的曲線?

dt <- rgamma(100, shape = 2.59, scale = 0.16)

n <- 1000
x <- seq(min(dt), max(dt), length.out = n) 

hist(dt, freq = FALSE, ylim = c(0, 2.5), xlab = "D")
curve(dgamma(x, shape = 2.59, scale = 0.16), add = TRUE, lwd = 2, n = n)

曲線有一個n屬性,默認為101 ,你需要增加它。 所以請注意,不是您輸入的數據點決定您的分辨率。

curve(dgamma(x, shape = 2.59, scale = 0.16), add = TRUE, lwd = 2, n = n) # then it takes your defined n = 1000

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM