ggplot2 – jitter and position dodge together

In ggplot2 version 1.0.0 there is new position named position_jitterdodge() that is made for such situation. This postion should be used inside the geom_point() and there should be fill= used inside the aes() to show by which variable to dodge your data. To control the width of dodging argument dodge.width= should be used.

ggplot(ex5, aes(x=tailindex, y=hillest, color=memorypar, fill=memorypar)) +
      facet_wrap(~process, nrow=2) +
      geom_point(position=position_jitterdodge(dodge.width=0.9)) +
      geom_boxplot(fill="white", outlier.colour=NA, position=position_dodge(width=0.9))

enter image description here

Leave a Comment