Part 62 Guides

Guides are the instructions for how to read the scales on your plot. The two major kinds of guides are axes and legends. You can customize the appearance of your guides using the guides() and guide_*() functions.

p <- data.frame(
  x = 1:5, y = 1:5, p = 1:5, q = 1:5, r = factor(1:5)
  ) %>% 
  ggplot() +
  aes(x, y, colour = p, size = q, shape = r) +
  geom_point() +
  scale_size_continuous(range = c(4, 8)) +
  theme_classic()
  
p

# Legends will be combined if they have the same type, values, and titles 
p + 
  guides(
    colour = guide_legend(title = "title"),
    size = guide_legend(title = "title"),
    shape = guide_legend(title = "title")
 )

# If all you want to change is the title of the guides, you can use labs()
p + 
  labs(
    color = "title",
    size = "title",
    shape = "title"
  )