r - How to add jitter to geom_point when already using dodge -


i'm plotting summary stats in front of individual geom_points, can't figure out how add jitter plots. think issue i'm using position argument move high , low water points away 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 plot produces (obviously not finished color scheme, etc) enter image description here

i'd point jittered within each point group (ie, not in straight line). help!


answer: use position_jitterdodge

amended code , 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() 

enter image description here

drey answered this.

answer: use position_jitterdodge

amended code , 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() 

enter image description here


Comments