library(ggplot2)
# first plot
p1 <- ggplot(
data = subset(iris, iris$Species == "setosa"),
aes(x = Sepal.Length, y = Sepal.Width)
) +
geom_point() +
labs(title = "setosa")
# second plot
p2 <- 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(
plotlist = list(p1, p2),
plotgrid.args = list(nrow = 1),
annotation.args = list(
tag_levels = "a",
title = "Dataset: Iris Flower dataset",
subtitle = "Edgar Anderson collected this data",
caption = "Note: Only two species of flower are displayed",
theme = theme(
plot.subtitle = element_text(size = 20),
plot.title = element_text(size = 30)
)
)
)
Run the code above in your browser using DataLab