ggplot2 Theme

aviral-goel

I use ggplot2 nowadays for all my graphing requirements because my research is on improving R and alternatives such as matplotlib are abysmal. This article is a collection of theme settings I have found useful, especially for generating figures for my recent publication on R.

For generating colorless background figures, I use the following theme setting.

old_theme <- theme_set(theme_bw() +
                       theme(text = element_text(size = 15), panel.border = element_blank()))

This is how the figures look like before and after updating the theme.

Figure 1: Figure without updated theme

Figure 1: Figure without updated theme

Figure 2: Figure with updated theme

Figure 2: Figure with updated theme

These figures were generated from the following code snippet.

library(ggplot2)

ggplot(mpg, aes(class)) +
geom_bar()