Agenda


Modify legend when the aesthetics are mapped to variables. Specifically

  • title
  • breaks
  • limits
  • range
  • labels
  • values
  • symbol type

Intro


Quite often the aesthetics are mapped to variables ggplot2 automatically creates legends wherever applicable. You may want to modify the appearance of legends. In this module, we will learn to modify the legends when the following aesthetics are mapped to categorical/continuous variables

  • continuous variables
    • alpha
    • size
  • discrete variables
    • alpha
    • color
    • fill
    • shape
    • size

Libraries


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

Continuous Variables


If you have mapped aesthetics to a continuous variable, you can modify the legend

  • title
  • breaks
  • limits
  • range
  • and labels

Map Size to Continuous Variable


ggplot(mtcars) +
  geom_point(aes(disp, mpg, size = hp))