Skip to content

Instantly share code, notes, and snippets.

@baptiste
Last active May 8, 2019 09:42
Show Gist options
  • Save baptiste/8db48ede1eacb22cdd78093f715cb945 to your computer and use it in GitHub Desktop.
Save baptiste/8db48ede1eacb22cdd78093f715cb945 to your computer and use it in GitHub Desktop.
library(ggplot2)
# dput(ls(pattern = "theme",package:ggplot2))
defaults <- c("theme_bw", "theme_classic", "theme_dark",
"theme_grey", "theme_light", "theme_linedraw",
"theme_minimal", "theme_void")
library(ggthemes)
# dput(ls(pattern = "theme",package:ggthemes))
addons <- c("theme_base", "theme_calc", "theme_economist",
"theme_economist_white", "theme_excel", "theme_few", "theme_fivethirtyeight",
"theme_foundation", "theme_gdocs", "theme_hc", "theme_igray",
"theme_map", "theme_pander", "theme_par", "theme_solarized",
"theme_solarized_2", "theme_solid", "theme_stata", "theme_tufte",
"theme_wsj")
p <- ggplot(mtcars) + facet_wrap(~vs) +
stat_qq(aes(sample = mpg, colour = factor(cyl)), geom="line")
pl1 <- lapply(defaults, function(th) p + get(th)() + ggtitle(th))
pl2 <- lapply(addons, function(th) p + get(th)() + ggtitle(th))
library(gridExtra)
library(Cairo)
CairoPDF("all_themes.pdf", width=8, height=32)
grid.arrange(arrangeGrob(grobs=pl1, top = "Original themes", ncol=2),
arrangeGrob(grobs=pl2, top = "Third-party themes", ncol=2), heights=c(0.4, 1))
dev.off()
@baptiste
Copy link
Author

all_themes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment