Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update arranging-plots.qmd #391

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions arranging-plots.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Often, one wants to show two or more plots side by side to show different aspect
This is the scenario that patchwork was build to solve.
At its heart, patchwork is a package that extends ggplot2's use of the `+` operator to work between multiple plots, as well as add additional operators for specialized compositions and working with compositions of plots.

As an example of the most basic use of patchwork, we'll use the following 4 plots of the `mpg` dataset
As an example of the most basic use of patchwork, we'll use the following 4 plots of the `mpg` dataset.

```{r}
p1 <- ggplot(mpg) +
Expand Down Expand Up @@ -85,7 +85,7 @@ p1 / p2
p3 | p4
```

patchwork allows nesting layouts which means that it is possible to create some very intricate layouts using just these two operators
patchwork allows nesting layouts which means that it is possible to create some very intricate layouts using just these two operators:

```{r}
p3 | (p2 / (p1 | p4))
Expand Down Expand Up @@ -165,15 +165,15 @@ The titles formatted according to the theme specification in the `plot_annotatio
p34 + plot_annotation(theme = theme_gray(base_family = "mono"))
```

As the global theme often follows the theme of the subplots, using `&` along with a theme object will modify the global theme as well as the themes of the subplots
As the global theme often follows the theme of the subplots, using `&` along with a theme object will modify the global theme as well as the themes of the subplots.

```{r}
p34 & theme_gray(base_family = "mono")
```

Another type of annotation, known especially in scientific literature, is to add tags to each subplot that will then be used to identify them in the text and caption.
ggplot2 has the `tag` element for exactly this and patchwork offers functionality to set this automatically using the `tag_levels` argument.
It can generate automatic levels in latin characters, arabic numerals, or roman numerals
It can generate automatic levels in latin characters, arabic numerals, or roman numerals.

```{r}
p123 <- p1 | (p2 / p3)
Expand Down