Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Know your problem
Know your data
Visualize your data - pie charts
Work with your chart
15. A qualitative color scale for the nominal variable
Check yourself


Use a qualitative color scale for the nominal variable. This will help the reader distinguish groups.

A qualitative color scale should be used for elements that encode the nominal variable. Nominal variables have no natural order; they simply present different categories. The most important thing you can do for the nominal variable is to make each category easily distinguishable. And as you remember, the qualitative color scale is designed to do that.

Cynthia Brewer has created some of the most popular palettes for each color scale. You can see them on her website You can access her scales in ggplot2 by adding this command:

+ scale_fill_brewer(type = scale_type, palette = palette_name )

The first argument allows you to specify a scale type, and the second allows you to choose a specific palette. All available palettes are presented in our Color Card, which you can find in the right navigation tab. Have a look at them and see which you like the best.


Choose your own qualitative scale from the Color Card and apply it to our chart. Add this command to the pie object:

scale_fill_brewer(type = scale_type, palette = palette_name )

Use "qual" as the type argument. Enter the name of the palette (e.g. "Accent") in the second argument.

When you're done, press the Run and Check Code button.

Stuck? Here's a hint!

You should write:

scale_fill_brewer(type = "qual", palette = "Accent" )