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

Connected

Exercise

Updating aesthetic labels

In this exercise, you'll modify some aesthetics to make a bar plot of the number of cylinders for cars with different types of transmission.

You'll also make use of some functions for improving the appearance of the plot.

  • labs() to set the x- and y-axis labels. It takes strings for each argument.
  • scale_fill_manual() defines properties of the color scale (i.e. axis). The first argument sets the legend title. values is a named vector of colors to use.

Instructions 1/3

undefined XP
  • 1

    Set the x-axis label to "Number of Cylinders", and the y-axis label to "Count" using the x and y arguments of labs(), respectively.

  • 2

    Implement a custom fill color scale using scale_fill_manual(). Set the first argument to "Transmission", and values to palette.

  • 3

    Modify the code to set the position to dodge so that the bars for transmissions are displayed side by side.