在同一个图中用不同颜色绘制多个 fitdist 对象?

Plot multiple fitdist objects in same the plot with different colors?

我有一个 fitdist 对象的列表,我使用这段代码存储了这些对象。

norm_dist_res <- list()
for(i in 1:10)
{
  x <- 1+(8000*(i-1))
  y <- 8000*i
  print (x)
  print(y)
  norm_dist_res[[i]] = norm_dist_res[[i]] <- fitdist(data=as.vector(g_all_p$data[x:y,]), distr="norm")

}

有没有办法用不同的颜色绘制从 fittest 中提取的所有正态分布,以显示数据的分布情况?

或者一般来说如何可视化多个正态分布?

您正在估计正态分布的参数,因此只需绘制密度图。

## Don't no what g_all_p is, so simplifying the data
library(fitdistrplus)
norm_dist_res <- list()
for(i in 1:10)
{
  norm_dist_res[[i]] = norm_dist_res[[i]] <- fitdist(data=rnorm(10), distr="norm")

}

然后只需使用 lines 绘图并更改颜色

x = seq(-5, 5, length.out=100)
plot(x, type="n", ylim=c(0, 1), xlim=range(x))
for(i in 1:10) {
  est = norm_dist_res[[i]]$estimate
  lines(x, dnorm(x, est[1], est[2]), col="grey90")
}

得到