16.5 More than one plot
There are several ways to place more than one plot side by side. One of the easiest is to use patchwork.
Install
install.packages("patchwork")
Load
library(patchwork)
This time we store our plots as variables
<- ggplot(data = penguins, aes(x = sex, fill = island)) +
barGraph geom_bar()
<- ggplot(data = penguins, aes(x = sex, y = body_mass_g, colour = species)) +
dotPlot geom_jitter(width = 0.1)
Then patchwork will arrange them
+ dotPlot barGraph
/ dotPlot barGraph
There are many ways in which patchwork can arrange plots. See the chapter Arranging Plots in ggplot2: Elegant Graphics for Data Analysis for more complex examples.