# combine_plots

0th

Percentile

##### Combining and arranging multiple plots in a grid

Wrapper around plot_grid that will return a plotgrid along with a combination of title, caption, and annotation label

##### Usage
combine_plots(
...,
title.text = NULL,
title.color = "black",
title.size = 16,
title.vjust = 0.5,
title.hjust = 0.5,
title.fontface = "bold",
caption.text = NULL,
caption.color = "black",
caption.size = 10,
caption.vjust = 0.5,
caption.hjust = 0.5,
caption.fontface = "plain",
sub.text = NULL,
sub.color = "black",
sub.size = 12,
sub.vjust = 0.5,
sub.hjust = 0.5,
sub.fontface = "plain",
sub.x = 0.5,
sub.y = 0.5,
sub.angle = 0,
sub.lineheight = 0.9,
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
...

Arguments passed on to cowplot::plot_grid

plotlist

(optional) List of plots to display. Alternatively, the plots can be provided individually as the first n arguments of the function plot_grid (see examples).

align

(optional) Specifies whether graphs in the grid should be horizontally ("h") or vertically ("v") aligned. Options are "none" (default), "hv" (align in both directions), "h", and "v".

axis

(optional) Specifies whether graphs should be aligned by the left ("l"), right ("r"), top ("t"), or bottom ("b") margins. Options are "none" (default), or a string of any combination of l, r, t, and b in any order (e.g. "tblr" or "rlbt" for aligning all margins). Must be specified if any of the graphs are complex (e.g. faceted) and alignment is specified and desired. See align_plots() for details.

nrow

(optional) Number of rows in the plot grid.

ncol

(optional) Number of columns in the plot grid.

rel_widths

(optional) Numerical vector of relative columns widths. For example, in a two-column grid, rel_widths = c(2, 1) would make the first column twice as wide as the second column.

rel_heights

(optional) Numerical vector of relative rows heights. Works just as rel_widths does, but for rows rather than columns.

labels

(optional) List of labels to be added to the plots. You can also set labels="AUTO" to auto-generate upper-case labels or labels="auto" to auto-generate lower-case labels.

label_size

(optional) Numerical value indicating the label size. Default is 14.

label_fontfamily

(optional) Font family of the plot labels. If not provided, is taken from the current theme.

label_fontface

(optional) Font face of the plot labels. Default is "bold".

label_colour

(optional) Color of the plot labels. If not provided, is taken from the current theme.

label_x

(optional) Single value or vector of x positions for plot labels, relative to each subplot. Defaults to 0 for all labels. (Each label is placed all the way to the left of each plot.)

label_y

(optional) Single value or vector of y positions for plot labels, relative to each subplot. Defaults to 1 for all labels. (Each label is placed all the way to the top of each plot.)

hjust

Adjusts the horizontal position of each label. More negative values move the label further to the right on the plot canvas. Can be a single value (applied to all labels) or a vector of values (one for each label). Default is -0.5.

vjust

Adjusts the vertical position of each label. More positive values move the label further down on the plot canvas. Can be a single value (applied to all labels) or a vector of values (one for each label). Default is 1.5.

scale

Individual number or vector of numbers greater than 0. Enables you to scale the size of all or select plots. Usually it's preferable to set margins instead of using scale, but scale can sometimes be more powerful.

greedy

(optional) How should margins be adjusted during alignment. See align_plots() for details.

cols

Deprecated. Use ncol.

rows

Deprecated. Use nrow.

title.text

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

title.color

Text color for title.

title.size

Point size of title text.

title.vjust

Vertical justification for title. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.

title.hjust

Horizontal justification for title. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.

title.fontface

The font face ("plain", "bold" (default), "italic", "bold.italic") for title.

caption.text

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

caption.color

Text color for caption.

caption.size

Point size of title text.

caption.vjust

Vertical justification for caption. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.

caption.hjust

Horizontal justification for caption. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.

caption.fontface

The font face ("plain" (default), "bold", "italic", "bold.italic") for caption.

sub.text

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

sub.color

Text color for annotation label (Default: "black").

sub.size

Point size of annotation text (Default: 12).

sub.vjust

Vertical justification for annotation label (Default: 0.5).

sub.hjust

Horizontal justification for annotation label (Default: 0.5).

sub.fontface

The font face ("plain" (default), "bold", "italic", "bold.italic") for the annotation label.

sub.x

The x position of annotation label (Default: 0.5).

sub.y

The y position of annotation label (Default: 0.5).

Vertical padding. The total vertical space added to the label, given in grid units. By default, this is added equally above and below the label. However, by changing the y and vjust parameters, this can be changed (Default: ggplot2::unit(1, "lines")).

sub.angle

Angle at which annotation label is to be drawn (Default: 0).

sub.lineheight

Line height of annotation label.

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).

##### Value

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

##### References

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

##### Aliases
• combine_plots
##### Examples
# NOT RUN {
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_plots(
p1,
p2,
labels = c("(a)", "(b)"),
title.text = "Dataset: Iris Flower dataset",
caption.text = "Note: Only two species of flower are displayed",
title.color = "red",
caption.color = "blue"
)
# }

Documentation reproduced from package ggstatsplot, version 0.3.1, License: GPL-3 | file LICENSE

### Community examples

Looks like there are no examples yet.