View source: R/alignpatch-align_plots.R
align_plots | R Documentation |
Arrange multiple plots into a grid
align_plots(
...,
ncol = NULL,
nrow = NULL,
byrow = TRUE,
widths = NA,
heights = NA,
design = NULL,
guides = waiver(),
theme = NULL
)
... |
<dyn-dots> A list of plots, ususally the
ggplot object. Use |
ncol , nrow |
The dimensions of the grid to create - if both are |
byrow |
If |
widths , heights |
The relative widths and heights of each column and row
in the grid. Will get repeated to match the dimensions of the grid. The
special value of |
design |
Specification of the location of areas in the layout. Can
either be specified as a text string or by concatenating calls to
|
guides |
A string with one or more of |
theme |
A |
An alignpatches
object.
layout_design()
layout_title()
layout_annotation()
# directly copied from patchwork
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))
p5 <- ggplot(mtcars) +
geom_violin(aes(cyl, mpg, group = cyl))
# Either add the plots as single arguments
align_plots(p1, p2, p3, p4, p5)
# Or use bang-bang-bang to add a list
align_plots(!!!list(p1, p2, p3), p4, p5)
# Match plots to areas by name
design <- "#BB
AA#"
align_plots(B = p1, A = p2, design = design)
# Compare to not using named plot arguments
align_plots(p1, p2, design = design)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.