can one offset jitter points in ggplot boxplot

元气小坏坏 提交于 2019-12-01 05:57:10

If we convert group to numeric and then add an offset, you seem to get your desired output. There is probably a more effective / efficient way, but give this a whirl:

ggplot(dat, aes(group, values)) + 
  geom_boxplot(outlier.size = 0) + 
  geom_point(aes(x = as.numeric(group) + .25, colour=group), alpha=0.7) + 
  ylim(0, 1) + stat_summary(fun.y=mean, shape=3, col='red', geom='point') +
  opts(legend.position = "right") + ylab("values") + xlab("group")

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!