Consider the mpg
data set found in the ggplot2
package. In this data set, there are 234 observations and 11 variables.
The plots in Figure 1 show the relationship between city and highway mileage for 38 popular models of cars. In Figure 1 (a) the points are colored by the number of cylinders while in Figure 1 (b) the points are colored by engine displacement.
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c() +
theme_minimal()
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c(option = "E") +
theme_minimal()
Example mirrored from:
https://quarto.org/docs/get-started/computations/rstudio.html#multiple-figures