Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot_spacer

Add a completely blank area


Description

This simple wrapper creates an empty transparant patch that can be added to push your other plots apart. The patch responds to adding theme() specifications, but only plot.background will have an effect.

Usage

plot_spacer()

Value

A ggplot object containing an empty plot

Examples

library(ggplot2)

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

p1 + plot_spacer() + p2


# To have more control over spacing, you can use the `plot.margin`
# parameter for `theme()` on each individual plot.

(p1 + theme(plot.margin = unit(c(0,30,0,0), "pt"))) +
(p2 + theme(plot.margin = unit(c(0,0,0,30), "pt")))

patchwork

The Composer of Plots

v1.1.1
MIT + file LICENSE
Authors
Thomas Lin Pedersen [cre, aut] (<https://orcid.org/0000-0002-5147-4711>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.