Description Usage Arguments Value Examples
While the use of +
is a natural way to add plots together, it can be
difficult to string together multiple plots programmatically if the number
of plots is not known beforehand. wrap_plots
makes it easy to take a list
of plots and add them into one composition, along with layout specifications.
1 2 |
... |
multiple |
ncol |
The dimensions of the grid to create - if both are |
nrow |
The dimensions of the grid to create - if both are |
byrow |
Analogous to |
widths |
The relative widths and heights of each column and row in the grid. Will get repeated to match the dimensions of the grid. |
heights |
The relative widths and heights of each column and row in the grid. Will get repeated to match the dimensions of the grid. |
A ggassemble
object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(ggplot2)
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))
p3 <- ggplot(mtcars) + geom_smooth(aes(disp, qsec))
p4 <- ggplot(mtcars) + geom_bar(aes(carb))
p5 <- ggplot(mtcars) + geom_violin(aes(cyl, mpg, group = cyl))
# Either add the plots as single arguments
wrap_plots(p1, p2, p3, p4, p5)
# Or add them as a list...
plots <- list(p1, p2, p3, p4, p5)
wrap_plots(plots)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.