Not long ago, I published a post “Three ggplot2 Themes Optimized for the Web”, where I made some tweaks to my three favorite ggplot2 themes – theme_bw(), theme_classic(), and theme_void() – to make them more readable and generally look better in graphics posted online, particularly in blog posts and similar publications.
I was happy to see that some people liked those and suggested that I should make a package. I tended to view packages as large collections of code and functions, but as Sébastien Rochette wisely put it, “If you have one function, create a package! If this simplifies your life, why not?” And since I will be frequently using these themes in subsequent posts, I’d like to make it as convenient as possible for the reader to install and use them.
So here is the ggwebthemes package! It has the same three themes, which I have tweaked and improved some more.
The package is not yet on CRAN. You can install ggwebthemes from GitLab:
# option 1: install using devtools # install.packages("devtools") devtools::install_gitlab("peterbar/ggwebthemes") # option 2: install using remotes # install.packages("remotes") remotes::install_gitlab("peterbar/ggwebthemes") # option 3: build from source # use if you get error: package 'ggplot2' was built under R version... install.packages("https://gitlab.com/peterbar/ggwebthemes/-/raw/master/tar/ggwebthemes_0.1.1.tar.gz", repos = NULL, type = "source") # load ggwebthemes library(ggwebthemes)
Please report bugs and/or submit feature requests here. Since I am currently using WordPress (but thinking about switching to a static site), I am particularly interested in how these themes would behave on Hugo and in blogs created with R Markdown/blogdown, so if you have any feedback, it will be most appreciated.
You can find the package’s reference manual here.
Note: To avoid confusing the readers, I will be removing the original post “Three ggplot2 Themes Optimized for the Web”, which contains early versions of these themes. You can still find it on R-Bloggers in case you need it.