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:
- If you want to distinguish groups, you need a qualitative scale.
- If you want to highlight the order of variables, you need a sequential scale.
- 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:
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.