我在单个 geom_points 前面绘制摘要统计信息,但无法弄清楚如何在图中添加抖动。我认为问题在于我已经在使用位置参数将高水位和低水位移开。
waterSymPop_p <- ggplot(aes(x = SymPop, y = Finish, fill = Water, color = Water), data = xanFull) +
geom_point(position = position_dodge(width = 0.9)) +
stat_summary(fun.data = "mean_cl_normal", geom = "pointrange", position = position_dodge(width = 0.9)) +
coord_flip()
我希望该点在每个点组内略微抖动(即,不在一条直线上)。谢谢您的帮助!
答案:使用position_jitterdodge
修改后的代码和新图:
ggplot(aes(x = SymPop, y = Finish, fill = Water, color = Water), data = xanFull) +
geom_point(position = position_jitterdodge(dodge.width = 0.9, jitter.width = 0.2)) +
stat_summary(fun.data = "mean_cl_normal", geom = "pointrange", position = position_dodge(width = 0.9)) +
coord_flip()