我想创建一个密度为R的x轴旋转为不同值的线图
假设我有三个密度h1,h2,h3
h1<-rnorm(100); h2<-rnorm(100,2,1); h3<-rnorm(100,5,1);
我想绘制一条线(在x轴上表示h1,h2和h3的均值),并且h1,h2和h3的密度图应在相应位置的线图上旋转(轴不可见)。
你的意思是这样吗?我发现您的问题不清楚。
require(ggplot2)
require(reshape2)
require(plyr)
#reshape into long format; also calculate mean for each group
tmp <- data.frame(h1=rnorm(100), h2=rnorm(100,2,1), h3=rnorm(100,5,1))
ggplot(ddply(melt(tmp),.variables=.(variable),transform,mean=mean(value)),aes(x=mean,y=value,group=variable)) + geom_violin()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句