Reputation: 6409
I have created several plots in ggplot called stored as plot1, plot2, plot3
I would like to create a single plot where each of the plots are displayed in subplots.
Is there a way to do this?
Upvotes: 0
Views: 241
Reputation: 81743
You can use grid.arrange
from package gridExtra
:
library(gridExtra)
grid.arrange(plot1, plot2, plot3)
An example:
library(ggplot2)
plot1 <- ggplot(mtcars, aes(mpg, cyl)) +
geom_point()
plot2 <- ggplot(mtcars, aes(disp, hp)) +
geom_line()
plot3 <- ggplot(mtcars, aes(vs, qsec)) +
geom_bar(stat = "identity")
library(gridExtra)
grid.arrange(plot1, plot2, plot3)
Upvotes: 2