3.9 Add text to a plot: geom_text()

  • This requires the use of the label aesthetic, along with others
# Filtering to simplify the example
mpg |> 
  filter(manufacturer == "ford") |>
  ggplot(aes(displ, hwy, label = model)) +
    geom_text()

  • position and other parameters are also useful.
mpg |> 
  filter(manufacturer == "ford") |>
  ggplot(aes(displ, hwy, label = model)) +
    geom_text(position = position_dodge(width = 0.2), angle = 45)