1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Visualization with ggplot2

Exercise

All about aesthetics: color vs. fill

Typically, the color aesthetic changes the outline of a geom and the fill aesthetic changes the inside. geom_point() is an exception: you use color (not fill) for the point color. However, some shapes have special behavior.

The default geom_point() uses shape = 19: a solid circle. An alternative is shape = 21: a circle that allow you to use both fill for the inside and color for the outline. This is lets you to map two aesthetics to each point.

All shape values are described on the points() help page.

fcyl and fam are the cyl and am columns converted to factors, respectively.

Instructions 1/3

undefined XP
  • 1

    Change the aesthetics so that fcyl maps to fill rather than color.

  • 2

    In geom_point() change the shape argument to 21 and add an alpha argument set to 0.6.

  • 3

    In the ggplot() aesthetics, map fam to color.