Reputation: 1947
Let's consider very simple plot and try to name it
library(ggplot2)
plot_1 <- ggplot() + aes(x = 1:10, y = 1:10) + geom_line()
patchwork::wrap_plots(plot_1, plot_1, plot_1, ncol = 1, nrow = 3) + ggtitle("a")
However, this code will only name the very last plot:
Is there any possibility that I can have a name for whole plot and not for only the last one ? i.e. to have a name in the place of black rectangle
Upvotes: 1
Views: 400
Reputation: 23767
you want plot_annotation
library(ggplot2)
library(patchwork)
plot_1 <- ggplot() + aes(x = 1:10, y = 1:10) + geom_line()
wrap_plots(rep(list(plot_1), 4), ncol = 2, nrow = 2) +
plot_annotation(title = "a")&
theme(plot.title = element_text(hjust = .5))
Created on 2021-03-03 by the reprex package (v1.0.0)
Upvotes: 2