Capítulo 12 Facetas

Las facetas tienen por objeto segmentar gráficos, en función de una variable categórica.

library(reticulate)
library(gcookbook)
library(ggplot2)
library(dplyr)

12.1 Crear el gráfico base

CO2_plot <- ggplot(CO2, aes(x = conc, y = uptake)) +
  geom_point()

12.2 Crear facetas horizontales

CO2_plot +
  facet_grid(. ~ Type)

12.3 Crear facetas verticales

CO2_plot +
 facet_grid(Treatment ~ .)

12.4 Crear facetas con doble entrada

CO2_plot +
 facet_grid(Treatment ~ Type)