Reputation: 175
I'm plotting summary stats in front of individual geom_points, but can't figure out how to add jitter to the plots. I think the issue is that I'm already using the position argument to move the High and Low water points away from each other.
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()
Here's the plot that produces (obviously not finished with the color scheme, etc)
I'd like the point to be slightly jittered within each point group (ie, not in a straight line). Thanks for the help!
Answer: use position_jitterdodge
Amended code and new figure:
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()
Upvotes: 1
Views: 4076
Reputation: 175
Drey answered this.
Answer: use position_jitterdodge
Amended code and new figure:
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()
Upvotes: 2