Exercises

  • map to continuous values
  • gradient scale
ggplot(mpg, aes(cty, hwy, colour = displ)) + geom_point()

  • categorical variable
  • unique colour
ggplot(mpg, aes(cty, hwy, colour = class)) + geom_point()

  • more than one aesthetic
ggplot(mpg, aes(cty, hwy, colour = class, size = displ)) + geom_point()

  • throw error
  • shapes discrete
ggplot(mpg, aes(cty, hwy, shape = displ)) + geom_point()

ggplot(mpg, aes(cty, hwy, shape = trans)) + geom_point()
## Warning: The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate
## ℹ you have requested 10 values. Consider specifying shapes manually if you need that many have them.
## Warning: Removed 96 rows containing missing values or values outside the scale range (`geom_point()`).

  • 6 shapes used but need 10