Know your data
Visualize your data – categorical variables
Work with your chart 2
12. Using color scales
Check yourself 2

Instruction

As you can see, ggplot2 automatically chooses colors for each category. You don't have to assign them when you build your chart. Nevertheless, you should always consider whether these automatic colors will meet your goals.

There are three main goals for color scales. These goals are expressed in the following ways:

  1. If you want to distinguish groups, you need a qualitative scale.
  2. If you want to highlight the order of variables, you need a sequential scale.
  3. If you want to show positive and negative differences from the norm, you need a diverging scale.

We'll focus on palettes that highlight the order of variables – i.e. sequential scales. Here's an example:

Color Scales

As you can see:

  • All colors come from one main color, so you have a natural feeling of continuity
  • Colors have different intensities and are easy to tell apart. They go from light to dark in equal intervals.
  • Colors can be ordered according to their shade, so it's easy to do the same with your data representations.

These three statements are the main features of every sequential scale.