The cowplot package is a simple add-on to ggplot. It provides various features that help with creating publication-quality figures, such as a set of themes, functions to align plots and arrange them into complex compound figures, and functions that make it easy to annotate plots and or mix plots with images. The package was originally written for internal use in my lab, to provide my students and postdocs with the tools to make high-quality figures for their publications. I have also used the package extensively in my book Fundamentals of Data Visualization. This introductory vignette provides a brief glance at the key features of the package.
For more complete documentation, read all vignettes and/or the reference documentation.
When I first wrote the cowplot package, its primary purpose was to provide a simple and clean theme, similar to ggplot2’s
theme_classic(). Therefore, I wrote the package to automatically load the theme. However, as the package grew in functionality, this choice was increasingly problematic, and therefore as of version 1.0 cowplot does not alter the default ggplot2 theme anymore.
Importantly, the cowplot package now provides a set of complementary themes with different features. I now believe that there isn’t one single theme that works for all figures, and therefore I recommend that you always explicitly set a theme for every plot you make.
library(ggplot2) library(cowplot) # default ggplot2 theme ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point()
# classic cowplot theme ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + theme_cowplot(12)
# minimal grid theme ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + theme_minimal_grid(12)
# minimal horizontal grid theme ggplot(iris, aes(Sepal.Length, fill = Species)) + geom_density(alpha = 0.5) + scale_y_continuous(expand = expansion(mult = c(0, 0.05))) + theme_minimal_hgrid(12)