Wrapper around cowplot::plot_grid that will return a plotgrid along with a combination of title, caption, and annotation label. This is a simpler version of the combine_plots function in this package.

combine_plots2(
  plotlist,
  plotgrid.args = list(),
  title.text = NULL,
  title.args = list(size = 16, fontface = "bold"),
  caption.text = NULL,
  caption.args = list(size = 10),
  sub.text = NULL,
  sub.args = list(size = 12),
  title.rel.heights = c(0.1, 1.2),
  caption.rel.heights = c(1.2, 0.1),
  title.caption.rel.heights = c(0.1, 1.2, 0.1),
  ...
)

Arguments

plotlist

A list of plots to display.

plotgrid.args

A list of additional arguments to cowplot::plot_grid.

title.text

String or plotmath expression to be drawn as title for the combined plot.

title.args, caption.args, sub.args

A list of additional arguments provided to title, caption and sub, resp.

caption.text

String or plotmath expression to be drawn as the caption for the combined plot.

sub.text

The label with which the combined plot should be annotated. Can be a plotmath expression.

title.rel.heights

Numerical vector of relative columns heights while combining (title, plot).

caption.rel.heights

Numerical vector of relative columns heights while combining (plot, caption).

title.caption.rel.heights

Numerical vector of relative columns heights while combining (title, plot, caption).

...

Currently ignored.

Value

Combined plot with title and/or caption and/or annotation label

References

https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/combine_plots.html

Examples

# loading the necessary libraries library(ggplot2) # preparing the first plot p1 <- ggplot2::ggplot( data = subset(iris, iris$Species == "setosa"), aes(x = Sepal.Length, y = Sepal.Width) ) + geom_point() + labs(title = "setosa") # preparing the second plot p2 <- ggplot2::ggplot( data = subset(iris, iris$Species == "versicolor"), aes(x = Sepal.Length, y = Sepal.Width) ) + geom_point() + labs(title = "versicolor") # combining the plot with a title and a caption combine_plots2( plotlist = list(p1, p2), plotlist.args = list(labels = c("(a)", "(b)")), title.text = "Dataset: Iris Flower dataset", caption.text = "Note: Only two species of flower are displayed", title.args = list(color = "red"), caption.args = list(color = "blue") )