Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thomasp85/patchwork
The Composer of ggplots
https://github.com/thomasp85/patchwork
ggplot-extension ggplot2 rstats visualization
Last synced: 1 day ago
JSON representation
The Composer of ggplots
- Host: GitHub
- URL: https://github.com/thomasp85/patchwork
- Owner: thomasp85
- License: other
- Created: 2017-11-28T20:55:08.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-09-16T10:15:53.000Z (4 months ago)
- Last Synced: 2025-01-06T22:05:40.094Z (8 days ago)
- Topics: ggplot-extension, ggplot2, rstats, visualization
- Language: R
- Homepage: https://patchwork.data-imaginist.com
- Size: 57 MB
- Stars: 2,492
- Watchers: 46
- Forks: 162
- Open Issues: 43
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-R - Patchwork - Combine separate ggplots into the same graphic. (2017)
- awesome-r-dataviz - patchwork - The Composer of ggplots. (ggplot / Miscellaneous)
- jimsghstars - thomasp85/patchwork - The Composer of ggplots (R)
- StarryDivineSky - thomasp85/patchwork
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
message = FALSE
)
```[![R-CMD-check](https://github.com/thomasp85/patchwork/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thomasp85/patchwork/actions/workflows/R-CMD-check.yaml)
[![CRAN_Release_Badge](http://www.r-pkg.org/badges/version-ago/patchwork)](https://CRAN.R-project.org/package=patchwork)
[![CRAN_Download_Badge](http://cranlogs.r-pkg.org/badges/patchwork)](https://CRAN.R-project.org/package=patchwork)
[![Codecov test coverage](https://codecov.io/gh/thomasp85/patchwork/branch/main/graph/badge.svg)](https://app.codecov.io/gh/thomasp85/patchwork?branch=main)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 arbitrarily complex layouts.## Installation
You can install patchwork from CRAN using `install.packages('patchwork')`.
Alternatively you can grab the development version from github using devtools:```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("thomasp85/patchwork")
```## Basic example
The usage of `patchwork` is simple: just add plots together!
```{r example}
library(ggplot2)
library(patchwork)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:```{r, message=FALSE}
p3 <- ggplot(mtcars) + geom_smooth(aes(disp, qsec))
p4 <- ggplot(mtcars) + geom_bar(aes(carb))(p1 | p2 | p3) /
p4
```## Learn more
patchwork can do so much more. Check out the guides for learning everything
there is to know about all the different features:- [Getting Started](https://patchwork.data-imaginist.com/articles/patchwork.html)
- [Assembling Plots](https://patchwork.data-imaginist.com/articles/guides/assembly.html)
- [Defining Layouts](https://patchwork.data-imaginist.com/articles/guides/layout.html)
- [Adding Annotation](https://patchwork.data-imaginist.com/articles/guides/annotation.html)
- [Aligning across pages](https://patchwork.data-imaginist.com/articles/guides/multipage.html)## Code of Conduct
Please note that the patchwork project is released with a [Contributor Code of Conduct](https://patchwork.data-imaginist.com/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.