An online community for showcasing R & Python tutorials. It operates as a networking platform for data scientists to promote their talent and get hired. Our mission is to empower data scientists by bridging the gap between talent and opportunity.
Visualizing Data

# ggplot2 themes examples

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 different themes just to have a sense of how they look like.
Enjoy!

## Bonus Track: The Code

Since copy and pasting and right-clicking 9 times to produce all the plots was definitely not acceptable, I wrote a small function to dynamically create and save a png file with different name and content. thank to Marcin Kosiński for the contribution (see comments)

library(dplyr)
library(ggplot2)

create_file_and_plot = function(name){
path = paste(getwd(),"/",name,".png",sep = '') %>%
file.path() %>%
png(,width=960,height=480)
eval(parse(text=paste0("print(ggplot(data=diamonds, aes(carat,price ))+ geom_point(aes(colour=  color))+", name,"())")))
dev.off()
}

sapply(c("theme_bw", "theme_dark"), create_file_and_plot)


### 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.