问题描述
如何让 ggplot2::stat_function 生成密度图而不是 geom = "line"?
My_table$distances
是数字
mixmdl <- mixtools::normalmixEM(My_table2$distances,k = 4)
plot_GMM(mixmdl,4)
mixmdl$posterior
x <- mixmdl$x
x <- data.frame(x)
GMMplot <- ggplot2::ggplot(data.frame(x)) +
ggplot2::geom_density(ggplot2::aes(x),color="black",alpha = .2) +
ggplot2::stat_function(geom = "line",fun = plot_mix_comps,args = list(mixmdl$mu[1],mixmdl$sigma[1],lam = mixmdl$lambda[1]),colour = "blue1",alpha = 1.5) +
xlab("distance (nm)")+theme_bw()+
theme(axis.title.y=element_blank(),axis.text.y=element_blank(),axis.ticks.y=element_blank(),legend.position = "none")+
ggplot2::stat_function(geom = "line",args = list(mixmdl$mu[2],mixmdl$sigma[2],lam = mixmdl$lambda[2]),colour = "blue2")+
ggplot2::stat_function(geom = "line",args = list(mixmdl$mu[3],mixmdl$sigma[3],lam = mixmdl$lambda[3]),colour = "blue3")+
ggplot2::stat_function(geom = "line",args = list(mixmdl$mu[4],mixmdl$sigma[4],lam = mixmdl$lambda[4]),colour = "blue4")+ylim(0.00,0.043)
GMMplot
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)