1 min read

Exploring ggplot2 themes

The ggplot2 package

The gpplot2 package is the ultimate in R graphics. Being able to create graphics in layers is simple, yet powerful concept. It’s probably one of the few R packages that everyone has heard of. One aspect of ggplot that is relatively underused is themes. This allows you style your plot in an easy and consistent way. For example, this plot

g = ggplot(mtcars, aes(mpg, disp)) + 

can be restyled via

g + theme_minimal()

There are numerous themes around in a variety of packages.

Exploring themes

To help explore themes, I wrote a little R package to automatically scan available themes. To install simply do the usual github install dance


Then load the package


The package contains one core function scan_themes(). To scan see the themes in the hrbrthemes package simply

scan_themes(g, pkg = "hrbrthemes")

Likewise, you can view themes in other packages in exactly the same view

scan_themes(g, pkg = "ggthemes")
scan_themes(g, pkg = "ggpplot2")

In fact, it should work with any package that uses the naming systems theme_*(). For example

scan_themes(g, "ggtech")

Try it out and let me know what you think!