I'm using emmeans
and would like to learn how to customize plots.
For a reproducible example, I'm using warpbreaks
data.
library(emmeans)
lm <- lm(breaks ~ wool * tension, data = warpbreaks)
emm <- emmeans(lm, ~ wool | tension)
plot <- plot(emm, horizontal=FALSE, comparisons=TRUE) + theme_bw()
plot
Instead of the default purple color, I'd like to customize confidence interval color by group, such that all six groups (L-A, L-B, M-A, M-B, H-A, H-B) would have confidence intervals in different colors. I'd also like to customize the shape of estimated means, instead of having them all as black dots.
Here's what I tried, but it didn't work.
plot +
scale_color_manual(values=c("#F8766D", "#B79F00", "#00BA38", "#00BFC4", "#619CFF", "#F564E3")) +
scale_shape_manual(values=c(1,2,3,4,5,6))
Any help would be appreciated!
Best bet is to call it with plotIt=FALSE
, and save the result, which is a data frame with all the plot info. Then you can plot that stuff any way you want.