Agenda


Learn to modify legend

  • title
  • label
  • bar

Libraries


library(ggplot2)
library(dplyr)
library(tidyr)

Title


  • position
    • top
    • bottom
    • left
    • right
  • alignment
    • 0 (left)
    • 1 (right)

Legend Title


ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c("red", "blue", "green"),
    guide = guide_legend(title = "Cylinders"))

Title Alignment


ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c(