this short post is exactly what it seems: a showcase of all ggplot2 themes available within the ggplot2 package. I was doing such a list for myself ( you know that feeling …”how would it look like with this theme? let’s try this one…”) and at the end I thought it could have be useful for my readers. At least this post will save you the time of trying all differents themes just to have a sense of how they look like.
Enjoy!

theme_bw()

theme_bw

theme_classic()

theme_classic

theme_dark()

theme_dark

theme_gray()

theme_gray

theme_grey()

theme_grey

theme_light()

theme_light

theme_linedraw()

theme_linedraw

theme_minimal()

theme_minimal

Bonus Track: The Code

Since copy and pasting and right-clicking 9 times to produce all the plots was definitely not acceptable, starting from a good post by Tony Cookson I wrote a small function to dinamically create and save a png file with different name and content:
library(dplyr)
library(ggplot2)
create_file <- function(name){
path <- paste(getwd(),"/",name,".png",sep = '') %>%
file.path() %>% png(,width=960,height=480)
}
#this is the template: change the theme (and the name argument) to produce the other plots
create_file(name = "theme_bw")
ggplot(data=diamonds, aes(carat,price ))+
geom_point(aes(colour= color))+
theme_bw()
dev.off()
view raw dynamic_plot.R hosted with ❤ by GitHub

Final notes

Inner ggplot2 structure allows for a nearly infinite number of customizations and extensions.You can have a sense of what I am talking about looking at ggplot2 extensions website or to the ggthemes package vignette by the package author  Jeffrey B. Arnold.
Advertisement

2 thoughts on “ggplot2 themes examples

  1. I liked your post. I always end up wondering what theme I should use. I particularly like the theme created with the cowplot package. It meets my needs for simple plots without having to think of every detail of ggplot2 plot. Sometimes we just need a quick plot and ggplot is not always fit for that.

    1. Thank you Jose, helping readers ‘wondering what theme’ should use was exactly the objective 🙂 . I appreciate cowplot as well, particularly the annotation and multiple plots features. Have you surfed http://www.ggplot2-exts.org ? It gives an overview on ggplot2 extensions, addiotional themes included.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s