These days, Cédric Scherer and I are writing the lessons about color for our ggplot2 Uncharted project. It’s a big work!
The main message of the lesson is something crucial:
Great visualizations don’t use color just for decoration: they use it with intent.
There are only three valid reasons to use color. Let's review them!
1️⃣ Colors to represent values
Use color to encode data in a perceptually linear way. The goal: emphasize one end of a range (sequential palette) or both ends (diverging palette). That's the case for a heatmap for instance! Without colors, no more meaning. So color is crucial here.
One of the most famous heatmap example. Shows the vaccine effect on Measles. D3 code.
2️⃣ Colors to distinguish groups
Use color to separate categories that have no intrinsic order. Each color should have similar visual weight so that all groups are shown equally (qualitative palette).
That's the one everyone forgets doing! Use color to draw attention to what matters most: a specific group, range, or threshold. Highlight colors work best when the rest of the chart is kept subtle and desaturated.
Roy Debatreyo (a student of my Matplotlib journey project) used a technique I love here: faceting + color highlight on each panel.
⚠️ A few exceptions
That's dataviz! There are rare cases where breaking the rule can make sense:
Double encoding: when color repeats information already shown on an axis, to reinforce a message.
Consistency across charts: when several charts show the same groups and you want colors to match.
That’s it for today!
Next time you add colors to a chart, check if they fit one of these three goals. If not: remove them.
See you next week,
Yan PS: In case you missed it, I built a tool to help you create a beautiful homepage in just a few minutes.
PPS: A few spots are still available for my Dataviz with Pythonworkshop this December!