ggstatsplot (version 0.0.7)

combine_plots: Combining and arranging multiple plots in a grid

Description

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.vpadding = grid::unit(1, "lines"), 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

...

Additional arguments used in the function cowplot::plot_grid().

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

sub.vpadding

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: grid::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://cran.r-project.org/package=ggstatsplot/vignettes/combine_plots.html

Examples

Run this code
# NOT RUN {
# 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_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"
)
# }

Run the code above in your browser using DataCamp Workspace