File: README.md

package info (click to toggle)
r-cran-patchwork 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,640 kB
  • sloc: sh: 15; makefile: 2
file content (83 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

<!-- README.md is generated from README.Rmd. Please edit that file -->

# patchwork <a href='https://patchwork.data-imaginist.com'><img src='man/figures/logo.png' align="right" height="131.5" /></a>

<!-- badges: start -->

[![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)
<!-- badges: end -->

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
# install.packages("devtools")
devtools::install_github("thomasp85/patchwork")
```

## Basic example

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

``` r
library(ggplot2)
library(patchwork)

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

p1 + p2
```

![](man/figures/README-example-1.png)<!-- -->

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
p3 <- ggplot(mtcars) + geom_smooth(aes(disp, qsec))
p4 <- ggplot(mtcars) + geom_bar(aes(carb))

(p1 | p2 | p3) /
      p4
```

![](man/figures/README-unnamed-chunk-2-1.png)<!-- -->

## 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.