Streamlined Plot Theme and Plot Annotations for 'ggplot2'

Some helpful extensions and modifications to the 'ggplot2' package. In particular, this package makes it easy to combine multiple 'ggplot2' plots into one and label them with letters, e.g. A, B, C, etc., as is often required for scientific publications. The package also provides a streamlined and clean theme that is used in the Wilke lab, hence the package name, which stands for Claus O. Wilke's plot package.


Build Status Coverage Status CRAN_Status_Badge CRAN_Downloads_Badge

The cowplot package is meant to provide a publication-ready theme for ggplot2, one that requires a minimum amount of fiddling with sizes of axis labels, plot backgrounds, etc. It meets my personal needs; you may or may not like my style.

The package also fixes a couple of other annoyances that I encountered when trying to use ggplot2 for publication-ready figures, in particular with respect to combining multiple plots into one figure and labeling these plots. It turns out that the easiest way to fix these issues was to implement a general-purpose drawing canvas on top of ggplot2, so as a side effect of this work you can do pretty crazy effects with ggplot2 graphs.

This package is available on CRAN here and can be installed via

install.packages("cowplot")

You can install the latest development version of this package using the devtools package. In your R console, simply enter:

devtools::install_github("wilkelab/cowplot")

Note that cowplot is in the early stages of development. While you may find it useful for certain graphing problems you encounter, it may have major problems or undergo substantial changes in the future. In particular, at this point I make no guarantees that the default theme will remain unchanged.

Usage

To get a quick introduction to the main features of this package, read the vignettes provided with the package on CRAN.

News

cowplot 0.9.2

  • Rewritten cowplot::ggsave function that calls ggplot2::ggsave
  • More robust handling of R graphics device weirdness/plots popping up in the wrong places

cowplot 0.9.1

  • Make examples and vignettes fail gracefully when magick package is not installed

cowplot 0.9.0

  • Added a theme for maps, theme_map(). Code provided by Spencer Fox, https://github.com/sjfox.
  • Added axis_canvas() function and related functions to make marginal plots and plot annotations simpler
  • Now export the plot_to_gtable function which converts most anything into a gtable for further use with cowplot
  • Added inherit.aes = FALSE to draw functions where needed
  • Added examples to various draw functions
  • Added draw_image() function to draw images onto plots

cowplot 0.8.0

  • The function plot_grid can now also handle base-R (graphics) plots. Code provided by https://github.com/flying-sheep.
  • More sophisticated plot alignments of complex plots are now possible. Code provided by Spencer Fox, https://github.com/sjfox.
  • Plot labels can now be styled. In particular, they follow the theme settings, e.g. if the theme uses a different font than default. This closes issue #37.
  • The positioning of plot labels in plot_grid can now be controlled with additional position parameters label_x and label_y. This closes issue #32.
  • Problems with elements from globally set themes leaking into the plot-grid background have been fixed. This closes issues #60, #63, #66.

cowplot 0.7.0

  • This version of cowplot has been prepared for the upcoming release of ggplot2 2.2.0. As a result of this upcoming switch, the function switch_axis_position() has been removed. Alternative axes will be natively supported by ggplot2 2.2.0.
  • As of this version, cowplot requires R >= 3.3.0. This dependency was added because R 3.3 fixes a critical problem with lists of units.

cowplot 0.6.3

cowplot 0.6.2

  • Updated plot_grid vignette so the tutorial on aligning plots of different types works again. This stopped working at some point and was removed from 0.6.1.

cowplot 0.6.1

  • Added new convenience function draw_figure_label() to label figures with labels such as "Figure 1".
  • Fixes in switch_axis_position() so that rotated axis labels work.
  • Fix missing axis lines in ggplot2 2.1

cowplot 0.6.0

Major changes:

  • Now requires ggplot2 version 2.0.0 or higher. Use cowplot 0.5.0 with older versions of ggplot2.
  • Because of the dependency on ggplot2 2.0.0, the default design is changed. No more bold face for axis labels
  • Add auto-generation of labels in plot_grid()
  • Add vignettes describing plot annotations and shared legends among plots

cowplot 0.5.0

Major changes:

  • Fix label positioning in plot_grid() so it is not affected by the scale parameter
  • Add draw_label() function which can draw both text and plotmath expressions
  • Add parameters hjust and vjust to plot_grid() to allow fine-tuning of label position
  • Add annotations underneath plot, via add_sub() function

Other changes:

  • Improve vignettes

cowplot 0.4.0

Major changes:

  • Added a function switch_axis_position() which can move/copy the x and/or y axis of a plot to the other side
  • plot_grid() can now align graphs
  • plot_grid() can now make grids with varying column widths and row heights

Other changes:

  • Various improvements in the documentation
  • Code has been separated into multiple files for easier maintenance

cowplot 0.3.1

Fix Vignette title

cowplot 0.3.0

First complete implementation ready for initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.