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:
Tag Archives: rainbow
Rainbow Colormaps – What are they good for? Absolutely nothing!
I’m probably preaching to the visualization choir here, but hopefully this could be helpful for newcomers to the field. This post is based on information given to me by my PhD-supervisor/anti-rainbow-colormap-activist Charl Botha. I’ll start off by explaining why rainbow colormaps are almost never a good choice with some references and will provide some good alternatives and resources at the end.
There are two main problems with using a rainbow colormap in (medical) visualization. The first is that it doesn’t have a natural ordering. If you ask people how they would rank yellow and blue, they have to guess. There is of course order in there (shorter to longer wavelength of light), but it’s not perceptually ordered .
The second problem is that it’s not perceptually linear, so equal distances in the scale do not appear equally different color-wise. For example, people perceive the 1st and the 5th colors in your colormap to be much more different than the 5th and the 9th, when these colors would be assigned to data-values that differ by identical amounts.This is actively misleading users. Furthermore, it introduces artifacts: There are perceived sharp transitions in data at the sharp transitions between hues . In the figure below this effect is clearly visible on an artificial dataset:
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 :
So by now, you may be asking yourself: ‘If you hate the rainbow colormap so much, why don’t you come up with a better one?’ The answer to this is, people have! But despite all the warnings, in the IEEE Visualization Conference proceedings of 2005, 52% of the medical papers and 59% of the non-medical papers still used the rainbow colormap . In any case, here are some alternatives you could consider (from , with examples added):
- 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