This is a wraper function around patchwork::wrap_plots() and
patchwork::plot_annotation() to arrange ggplot2 objects.
arrange_ggplot( ..., nrow = NULL, ncol = NULL, widths = NULL, heights = NULL, guides = NULL, design = NULL, legend.position = "bottom", title = NULL, subtitle = NULL, caption = NULL, tag_levels = NULL, tag_prefix = NULL, tag_suffix = NULL, tag_sep = NULL, theme = NULL )
| ... | multiple |
|---|---|
| nrow, ncol | The number of rows and columns, respectively. |
| 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. |
| guides | A string specifying how guides should be treated in the layout.
Defaults to |
| design | Specification of the location of areas in the layout. |
| legend.position | The position of the legends in the plot if
|
| title, subtitle, caption | Text strings to use for the various plot annotations. |
| tag_levels | A character vector defining the enumeration format to use
at each level. Possible values are |
| tag_prefix, tag_suffix | Strings that should appear before or after the tag. |
| tag_sep | A separator between different tag levels. |
| theme | A ggplot theme specification to use for the plot. Only elements related to the titles as well as plot margin and background is used. |
A patchwork object
# \donttest{ library(ggplot2) library(metan) p1 <- ggplot(mtcars, aes(wt, mpg)) + geom_point() p2 <- ggplot(mpg, aes(class, hwy)) + geom_boxplot() # Default plot arrange_ggplot(p1, p2)# Insert plot annotation, titles and subtitles arrange_ggplot(p1, p2, ncol = 1, tag_levels = list(c("(P1)", "(P2)")), title = "My grouped ggplot", subtitle = "Made with arrange_ggplot()", caption = "P1 = scatter plot\nP2 = boxplot", theme = theme(plot.title = element_text(size = 20, face = "bold"), plot.subtitle = element_text(size = 10, face = "italic"), plot.caption = element_text(size = 10, face = "italic")))# }