我有一个像这样的 ggplot2 分组箱线图
p <- qplot(factor(cyl), mpg, data=mtcars, geom="boxplot", fill=factor(gear))
我想透支平均点。我试过这个
p+ stat_summary(fun.y=mean, colour="red", geom="point")
but, I don't get the mean points over the boxes of each group.
我应该怎么做才能得到这个?
您应该将位置设置为position_dodge()
and width
到 0.75 - 因此点的放置方式与箱线图相同。
qplot(factor(cyl), mpg, data=mtcars, geom="boxplot", fill=factor(gear)) +
stat_summary(fun.y=mean, colour="red",
geom="point",position=position_dodge(width=0.75))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)