Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的 ggplot2 分组箱线图
p <- qplot(factor(cyl), mpg, data=mtcars, geom="boxplot", fill=factor(gear))
我想透支平均点。我试过这个
p+ stat_summary(fun.y=mean, colour="red", geom="point")
但是,我没有得到每组盒子的平均分。
我应该怎么做才能得到这个?
您应该将位置设置position_dodge()为width0.75 - 因此点的放置方式与箱线图相同。
position_dodge()
width
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))