cowplot::plot_grid()
with a
combination of title, caption, and annotation labelWrapper around plot_grid
that will return
a plotgrid along with a combination of title, caption, and annotation label
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))
Additional arguments used in the function cowplot::plot_grid()
.
String or plotmath expression to be drawn as title for the combined plot.
Text color for title.
Point size of title text.
Vertical justification for title. Default = 0.5
(centered
on y). 0
= baseline at y, 1 = ascender at y.
Horizontal justification for title. Default = 0.5
(centered on x). 0
= flush-left at x, 1
= flush-right.
The font face ("plain"
, "bold"
(default), "italic"
,
"bold.italic"
) for title.
String or plotmath expression to be drawn as the caption for the combined plot.
Text color for caption.
Point size of title text.
Vertical justification for caption. Default = 0.5
(centered on y). 0
= baseline at y, 1
= ascender at y.
Horizontal justification for caption. Default = 0.5
(centered on x). 0
= flush-left at x, 1
= flush-right.
The font face ("plain"
(default), "bold"
, "italic"
,
"bold.italic"
) for caption.
The label with which the combined plot should be annotated. Can be a plotmath expression.
Text color for annotation label (Default: "black"
).
Point size of annotation text (Default: 12
).
Vertical justification for annotation label (Default:
0.5
).
Horizontal justification for annotation label (Default:
0.5
).
The font face ("plain"
(default), "bold"
, "italic"
,
"bold.italic"
) for the annotation label.
The x position of annotation label (Default: 0.5
).
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: grid::unit(1, "lines")
).
Angle at which annotation label is to be drawn (Default:
0
).
Line height of annotation label.
Numerical vector of relative columns heights while combining (title, plot).
Numerical vector of relative columns heights while combining (plot, caption).
Numerical vector of relative columns heights while combining (title, plot, caption).
Combined plot with title and/or caption and/or annotation label
https://cran.r-project.org/package=ggstatsplot/vignettes/combine_plots.html
# 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 DataLab