Global vs. Local Aesthetics

Global aesthetics:

  • in ggplot()
  • apply to all layers
ggplot(
  data = penguins,
  mapping = aes(
    x = flipper_length_mm, 
    y = body_mass_g, 
    color = species
  )
) +
  geom_point() +
  geom_smooth(method = "lm")

Local aesthetics:

  • in geom_*()
  • apply only to that layer.
ggplot(
  data = penguins,
  mapping = aes(
    x = flipper_length_mm, 
    y = body_mass_g
  )
) +
  geom_point(
    aes(color = species)) +
  geom_smooth(method = "lm")