Agenda


In this module, we will continue to explore different ways to modify/customize the legend of plots including:

  • position
  • alignment
  • direction
  • legend bar
    • width
    • height
    • bins
    • ticks
    • limits

Libraries


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

Position


  • position
    • top
    • bottom
    • left
    • right

Position


ggplot(mtcars) + geom_point(aes(disp, mpg, color = factor(cyl))) +
  scale_color_manual(values = c("red", "blue", "green"),
    guide = guide_legend(label.position = "right"))