I'm trying to build a complex figure that overlays individual data points on a boxplot to display both summary statistics as well as dispersion of the raw data. I have 2 questions in rank order of importance:
- How do I center the jittered points around the middle of their respective box plot?
- How can I remove the dark dots from the "drv" legend?
Code:
library(ggplot2) library(dplyr) mpg$cyl <- as.factor(mpg$cyl) mpg %>% filter(fl=="p" | fl=="r" & cyl!="5") %>% sample_n(100) %>% ggplot(aes(cyl, hwy, fill=drv)) + stat_boxplot(geom = "errorbar", width=0.5, position = position_dodge(1)) + geom_boxplot(position = position_dodge(1), outlier.shape = NA)+ geom_point(aes(fill=drv, shape=fl), color="black", show.legend=TRUE, alpha=0.5, size=3, position = position_jitterdodge(dodge.width = 1)) + scale_shape_manual(values = c(21,23)) 
