library(ggplot2)
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
ggtitle('Plot 1')
p2 <- ggplot(mtcars) +
geom_boxplot(aes(gear, disp, group = gear)) +
ggtitle('Plot 2')
p3 <- ggplot(mtcars) +
geom_point(aes(hp, wt, colour = mpg)) +
ggtitle('Plot 3')
p4 <- ggplot(mtcars) +
geom_bar(aes(gear)) +
facet_wrap(~cyl) +
ggtitle('Plot 4')
library(patchwork)3 Multiple ggplots with patchwork
The package patchwork (Pedersen (2025)) makes combining ggplots possible.
Example from here.
Plots next to each other
p1 + p2
Plots under each other
p1 /p2
All at once
p1 + p2 + p3 + p4