【发布时间】:2021-05-10 03:22:10
【问题描述】:
当我将lines() 添加到hist() 时,我得到无法解释的交叉线,你能告诉我为什么吗?请
x <-
rgamma(100, shape = 1, rate = 2)
gamma_distr <-
fitdistr(x, densfun="gamma")
pdf_gamma <-
dgamma(x,
shape = gamma_distr$estimate[1],
rate = gamma_distr$estimate[2])
hist(x, 100, freq = FALSE)
lines(x = x, y = pdf_gamma, col="red")
【问题讨论】:
-
因为
lines按给定值的顺序绘制:lines(x[order(x)], pdf_gamma[order(x)], col="red")