patchwork v1.0.0


Monthly downloads



The Composer of Plots

The 'ggplot2' package provides a strong API for sequentially building up a plot, but does not concern itself with composition of multiple plots. 'patchwork' is a package that expands the API to allow for arbitrarily complex composition of plots by, among others, providing mathematical operators for combining multiple plots. Other packages that try to address this need (but with a different approach) are 'gridExtra' and 'cowplot'.



R build
status CRAN\_Release\_Badge CRAN\_Download\_Badge Lifecycle:
experimental Codecov test

The goal of patchwork is to make it ridiculously simple to combine separate ggplots into the same graphic. As such it tries to solve the same problem as gridExtra::grid.arrange() and cowplot::plot_grid but using an API that incites exploration and iteration, and scales to arbitrily complex layouts.


You can install patchwork from github with:

# install.packages("devtools")

Basic example

The usage of patchwork is simple: just add plots together!


p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))

p1 + p2

patchwork provides rich support for arbitrarily complex layouts with full alignment. As an example, check out this very readable code for nesting three plots on top of a third:

p3 <- ggplot(mtcars) + geom_smooth(aes(disp, qsec))
p4 <- ggplot(mtcars) + geom_bar(aes(carb))

(p1 | p2 | p3) /

Learn more

patchwork can do so much more. Check out the guides for learning everything there is to know about all the different features:

Code of Conduct

Please note that the patchwork project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Functions in patchwork

Name Description
patchGrob Get a grob describing the content of a patch object
plot_arithmetic Plot arithmetic
wrap_plots Wrap plots into a patchwork
guide_area Add an area to hold collected guides
patchworkGrob Convert a patchwork to a gtable
plot_spacer Add a completely blank area
wrap_elements Wrap arbitrary graphics in a patchwork-compliant patch
wrap_ggplot_grob Make a gtable created from a ggplot object patchwork compliant
area Specify a plotting area in a layout
plot_layout Define the grid to compose plots in
multipage_align Align plots across multiple pages
patchwork-package patchwork: The Composer of Plots
plot_annotation Annotate the final patchwork
No Results!

Vignettes of patchwork

No Results!

Last month downloads


Type Package
License MIT + file LICENSE
Encoding UTF-8
LazyData true
RoxygenNote 6.1.1
VignetteBuilder knitr
NeedsCompilation no
Packaged 2019-11-28 09:24:23 UTC; thomas
Repository CRAN
Date/Publication 2019-12-01 12:40:02 UTC

Include our badge in your README