I know our post on or rather against the use of rainbow colormaps is one of the most well-read on our blog. It gets referenced quite a bit and is even used in visualization lectures. It’s been a while since it was written though, and now it seems like a good time for an update featuring the beautiful alternative colormaps now included in Matplotlib. Let’s start with a little teaser image:
This figure shows the same effect on a MRI scan of the head. The rainbow colormap creates perceived contours where there are none in the data, so that structures within these bands are not represented. On top of that attention is drawn to the yellow areas, because they are the brightest, but not necessarily the most important :
- For nominal data (data that doesn’t have implied order): use a selection of distinct colors. A good choice is a qualitative scheme from colorbrewer2.org, for example this colorblind safe four color qualitative scheme:
- For high-frequency ordinal data (data that does have order but no distance metric, including medical images): use gray-scale or heated body scale, for example the Gray colormap from Matlab or the Heated-Object scale colormap from Haim Lefkowitz’ color center.
- For colormaps on a surface: use an isoluminant colormap such as a saturation scale from for instance red to green or a double-ended scale like green to gray to red.
- For interval (measurable distances) and ratio (measurable distances and zero point) data: use a double-ended scale. The double-ended scale can be useful to indicate on which side of the zero a region lies. For instance if your scale goes from purple to white to green, the purple values will be below zero, while the green values will be above.
Besides just not using the rainbow colormap, you might also want to take factors like colorblind safety and printer friendliness (for papers) into account. To conclude this post, here are some resources you can use to pick a cool (or hot) colormap for your visualization needs:
- Colorbrewer: officially color advice for cartography, but has cool interactive features to see the effects of a chosen colormap on several types of data.
- Haim Levkowitz’s color center: features downloadable perceptually linear colour maps, including the heated-object scale.
- Matlab colormaps: Matlab has some pretty colormaps built in, like the heated body ‘Hot’ and other perceptually linear colormaps like Gray, Summer, Bone and Pink. Just stay away from those rainbows please 🙂
- Perceptually improved colormaps for Matlab: three perceptual colormaps with rainbow-like colors for interval data and a colormap for ratio data.
- Update: I have written a follow-up post on four new beautiful perceptually linear colormaps designed for Matplotlib, but free to use anywhere.
- : D. Borland and R. M. Taylor, “Rainbow Color Map (Still) Considered Harmful,” IEEE Computer Graphics and Applications, vol. 27, no. 2, pp. 14-17, Apr. 2007.
- : B. E. Rogowitz, L. A. Treinish, and S. Bryson, “How not to lie with visualization,” Computers in Physics, vol. 10, no. 3, pp. 268–273, 1996.
- Bonus: Drew Skau has also written a great blog post against rainbow colormaps
- Bonus 2: Another great article: Why Should Engineers and Scientists Be Worried About Color?
- Bonus 3: A series of posts on the rainbow and similar color palettes: The rainbow is dead… long live the rainbow!
- Bonus 4: And another amazing one by eagereyes: How The Rainbow Color Map Misleads
- Bonus 5: Matlab changed the default colormap away from the rainbow! Why you should dump the rainbow