+ - 0:00:00
Notes for current slide
Notes for next slide

Compound figures

Claus O. Wilke

last updated: 2024-04-22

Compound figures

Two common scenarios:

Compound figures

Two common scenarios:

1. The same type of plot is replicated many times (small multiples)

Compound figures

Two common scenarios:

1. The same type of plot is replicated many times (small multiples)

2. Several disparate plots are combined into one display

1. Small multiples (facets)

1. Small multiples (facets)

Avoid bars or other elements that are floating in space

1. Small multiples (facets)

Small multiples work even for massive amounts of data

y-axis ranges should be consistent among panels

y-axis ranges should be consistent among panels

2. Combining disparate figures into one display

2. Combining disparate figures into one display

Note: We now need plot labels ("a", "b") to identify sub-plots

Don't use overly large or otherwise prominent labels

Note: Also don't use serif fonts (such as Times) for labels

Use a consistent color language among sub-plots

Use a consistent color language among sub-plots

Pay attention to sub-plot alignment

Pay attention to sub-plot alignment

Combine plots of different types

This helps your readers to distinguish different parts of the analysis

Combine plots of different types

This helps your readers to distinguish different parts of the analysis

Combine plots of different types

This helps your readers to distinguish different parts of the analysis

Distinguish infographics from figures in article/book

There are two distinct use cases:

Distinguish infographics from figures in article/book

There are two distinct use cases:

Infographic: Standalone, has title/subtitle/caption

Distinguish infographics from figures in article/book

There are two distinct use cases:

Infographic: Standalone, has title/subtitle/caption

Figure in article/book: Caption contains title, not part of figure

Example of infographic

Figure 1. Corruption and human development. The most developed countries experience the least corruption. Inspired by a posting in The Economist online (2011). Data sources: Transparency International & UN Human Development Report.

Example of figure in article or book

Making compound plots in R

The patchwork package

library(patchwork)
# make first plot
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p1

The patchwork package

library(patchwork)
# make first plot
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
# make second plot
p2 <- ggplot(mtcars) +
aes(gear, disp, group = gear) +
geom_boxplot()
p2

The patchwork package

library(patchwork)
# make first plot
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
# make second plot
p2 <- ggplot(mtcars) +
aes(gear, disp, group = gear) +
geom_boxplot()
# place plots side-by-side
p1 | p2

The patchwork package

library(patchwork)
# make first plot
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
# make second plot
p2 <- ggplot(mtcars) +
aes(gear, disp, group = gear) +
geom_boxplot()
# place plots on top of one-another
p1 / p2

The patchwork package

# add a few more plots
p3 <- ggplot(mtcars) +
geom_smooth(aes(disp, qsec))
p4 <- ggplot(mtcars) +
geom_bar(aes(carb))
# make complex arrangement
(p1 | p2 | p3) / p4

Plot annotations and themes

(p1 | p2 | p3) / p4 +
plot_annotation(
tag_levels = "A"
)

Automatic labeling of plots

Plot annotations and themes

(p1 | p2 | p3) / p4 +
plot_annotation(
tag_levels = "a"
)

Automatic labeling of plots

Plot annotations and themes

(p1 | p2 | p3) / p4 +
plot_annotation(
tag_levels = "a"
) &
theme_minimal_grid()

Applying one theme to all plots

Plot annotations and themes

(p1 | p2 | p3) / p4 +
plot_annotation(
tag_levels = "a",
title = "A plot about mtcars",
subtitle = "With subtitle...",
caption = "...and caption"
) &
theme_minimal_grid()

Titles and captions

Further reading

Compound figures

Two common scenarios:

Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow