Examples for 'patchwork::plot_arithmetic'


Plot arithmetic

Aliases: plot_arithmetic -.ggplot /.ggplot |.ggplot *.gg &.gg

Keywords:

### ** Examples

library(ggplot2)

p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))
p3 <- ggplot(mtcars) + geom_bar(aes(gear)) + facet_wrap(~cyl)
p4 <- ggplot(mtcars) + geom_bar(aes(carb))

# Standard addition vs division
p1 + p2 + p3 + plot_layout(ncol = 1)
plot of chunk example-patchwork-plot_arithmetic-1
p1 + p2 - p3 + plot_layout(ncol = 1)
plot of chunk example-patchwork-plot_arithmetic-1
# Stacking and packing
(p1 | p2 | p3) /
      p4
plot of chunk example-patchwork-plot_arithmetic-1
# Add elements to the same nesting level
(p1 + (p2 + p3) + p4 + plot_layout(ncol = 1)) * theme_bw()
plot of chunk example-patchwork-plot_arithmetic-1
# Recurse into nested plots as well
(p1 + (p2 + p3) + p4 + plot_layout(ncol = 1)) & theme_bw()
plot of chunk example-patchwork-plot_arithmetic-1

[Package patchwork version 1.1.1 Index]