After being steadfastly against anything in R beyond base, I’ve recently been indoctrinated into the tidyverse way of doing things. In particular, ggplot and extensions has made making complicated plots a lot easier than using base graphics (especially ggpubr’s ggarrange() function for labelling panels, which I used to do with mtext()). However, I’ve never been a huge fan of the ggplot aesthetic, being trained from a young age to eschew “chart junk“, like grid lines and unnecessary backgrounds. It’s fairly easy to do, with a few modifications of ggplot’s theme_bw(). Include this code before your ggplot commands:
require(ggplot2) theme_gray() # the default theme p <- ggplot(mtcars, aes(wt, mpg)) q = p + geom_point(aes(colour=factor(cyl), size = qsec)) ggsave(q, filename = "theme_gray.png", device="png", width=4, height=3) ### Use this to make it look like base theme_set(theme_bw()) theme_update(text = element_text(size=12), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), strip.background = element_blank() ) ### ggsave(q, filename = "theme_base.png", device="png", width=4, height=3)
- “Theme base”
Done!