Exercise

All about aesthetics: color, shape and size

In the video you saw 9 visible aesthetics. Let's apply them to a categorical variable — the cylinders in mtcars, cyl.

These are the aesthetics you can consider within aes() in this chapter: x, y, color, fill, size, alpha, labels and shape.

One common convention is that you don't name the x and y arguments to aes(), since they almost always come first, but you do name other arguments.

In the following exercise the fcyl column is categorical. It is cyl transformed into a factor.

Instructions 1/4

undefined XP
  • 1

    Map mpg onto the x aesthetic, and fcyl onto the y.

  • 2

    Swap the mappings of the first plot: fcyl onto the x aesthetic, and mpg onto the y.

  • 3

    Map wt onto x, mpg onto y, and fcyl onto color.

  • 4

    Modify the point layer of the previous plot by changing the shape argument to 1 and increasing the size to 4.