This is the first post in a series on the rainbow and similar color palettes. My goal is to demonstrate it is not a good idea to use these palettes to display scientific data, and then answer these two questions: (1) is there anything we can do to “fix” the rainbow, and (2) if not, can we design a new one from scratch.
The rainbow is dead…some examples
In a previous post I showed a pseudo-3D rendering of my left hand x-ray using intensity (which is a measure of bone thickness) as the elevation. I mapped the rendering to both grayscale and rainbow color palettes, and here I reproduced the two images side by side:
I used this example to argue (briefly) that the rainbow obscures some details and confuses images by introducing artifacts. Notice that in this case it clearly reduces the effectiveness of the pseudo-3D rendering in general. It also introduces inversions in the perception of elevation. The thick part in the head of the radius bone, indicated by the arrow, looks like a depression, whereas it is clearly (and correctly) a high in the grayscale version.
In some case I cited a note  by the IBM Research Centre, which highlight how the rainbow color palette creates these perceptual artifacts (particularly the first two examples). I introduced the notion that rainbow is very confusing for people with color deficiencies (up to 8% in caucasian men), referencing an excellent simulation of these confusing effects shown in Fig.1 af an article  in the American Geophysical Union’s EOS publication. I also posted an example of my own in A rainbow for everyone.
In the figure below, from , I show a final, striking example. The image has three panels with the same bust colored using grayscale, heated body, and rainbow-like palette. Notice that not only is the latter confusing but also unpleasant and unnatural.
I wanted to understand a bit more the reason why is it so, and answer to the question: ‘is there anything we can do about it?’ Today’s post will focus on that. So, why does the rainbow looks and feels unpleasant and unnatural? Here’s the first clue. I converted the three panels above to intensity and then mapped them all to grayscale (the same result would be achieved in Photoshop or other software with a conversion to grayscale). The result is below: it tells me that it is the intensity information in the rainbow sequence of hues that is “not right”.
And yet the rainbow color palette is the most commonly used of all, across all scientific disciplines. Borland and Taylor in  quantify how widespread the use of rainbow is and point out that it is the default in the greatest majority of software packages. They also note that the medical and biomedical communities have caught up with this idea more rapidly and that different palettes are used by practitioners in those disciplines. A great example can be found in , where the authors argue that using rainbow in artery visualization has a negative impact on task performance, and may even cause a higher rate of heart disease misdiagnosis! Some alternative palettes that are preferable to the rainbow are recommended in those papers. From reading what I reported so far, and from several other papers and notes on the subject, I am convinced that the rainbow is not right. Then I asked myself: can I do anything to demonstrate it further, perhaps quantify it? I think I can answer this question, and will do it in the next section.
The visible (natural) spectrum in RGB and CIE L*a*b* color spaces
First I created a natural spectrum palette using the CIE 1931 modified by Judd and Vos (found here). In this palette the XYZ triplets represent colors sampled at a constant interval of 5 nanometer in the wavelength range 360-830. I reduced the palette to approximately the visible range (400-700 nm) and then converted the XYZ triplets to RGB values using this submissions (Spectral and xyz color functions) from the Matlab File Exchange. In the left panel of the figure below, I used the Great Pyramid of Giza as a test surface for this palette. The colorbar indicates elevation, which is in feet (easier to code as the total pyramid height in meters was a non integer number). I used the pyramid to assess how perceptual the natural spectrum palette is: because pyramids have monotonically increasing elevation there should be no discontinuities in the surface if the palette is perceptually monotonic. Instead, there are at least two major discontinuities visible in the pyramid (the yellow, and the blue) and they bound an area of nearly constant color (green). These are obviously artifacts and because the pyramid is a perfectly flat surface we know they are caused by the palette.
In addition to the above I tried a more quantitative assessment: I converted each of the 256 RGB triplets to CIE L*a*b* values to examine the behaviour of the lightness L*, the quantitative axis of CIE L*a*b* space. Since this color space was specifically designed to accurately map color perception it seemed an obvious test. In the right panel in the figure above I plotted L* against pyramid elevation so that the plot and the pyramid image can be easily be compared back and forth; to facilitate the task I also colored the L* plot line accordingly. To me this plot elegantly explains the artifacts in the pyramid by showing where lightness changes are non monotonic. For example L* it increases from black to purple, then flattens and drops from purple to blue, then it increases again through light blue and cyan, then it plateaus at the green, and so on. On top of that, the curve gradient changes in a number of places, indicating a non-uniform perceptual distance between samples. This is troublesome if the palette is used to map elevation because it will interfere with the correct perception of relief as we have seen with the pyramid. The effect would be even more confusing if shading is added. What happens then with surfaces that are not as regular as the pyramid? We may not be able to distinguish real edges from artifacts, therefore our ability to interpret is hindered. The takeaway is that yes the visible spectrum is a natural progression of colors in terms of wavelengths, but it is definitely a poor choice for surface mapping and visualization.
I shared in the previous post the code to create the pseudo-3D hand x-ray displays. To create the pyramid and L* plot to test your own palette you can use the code in the box below. In addition to the code snippet you will need to download these two submissions from the Matlab File Exchange: Colorspace transformations and Colormapline from the Matlab File Exchange. If you want to use the natural spectrum please download my RGB triplets and import them into Matlab.
%% This cell creates the Great Pyramid of Khufu in Giza % using the original(pre-erosion) dimensions of 755x755x482 feet % (I am using imperial measurements as they are round numbers % - metrics measurements are not) PY=zeros(241,241); for i = 1:241 temp=(0:1:i-1); PY(i,1:i)=temp(:); end test=PY.'; test=test-1; test(test==-1)=0; test1=test([2:1:end,1],:); PY1=PY+test1; PY2=fliplr(PY1); PY3= flipud(PY1); PY4=fliplr(PY3); GIZA=[PY1,PY2;PY3,PY4].*2; x=linspace(1,756,size(GIZA,1)); y=x; [X,Y]=meshgrid(x,y); clear i test test1 PY PY1 PY2 PY3 PY4 temp;
%% This cell plots the pyramid with SURF (interpolated color) fig1=figure; surf(X,Y,GIZA,GIZA,'FaceColor','interp','EdgeColor','none'); view(-35,70); colormap(Spectrum); axis off; grid off; colorbar; % set(fig1,'Position',[720 400 950 708]); % set(fig1,'OuterPosition',[716 396 958 790]); title('Natural spectrum','Color','k','FontSize',12,'FontWeight','demi');
%% This cell creates L* plot for natural spectrum LS=colorspace('RGB->Lab',spectrum); figure; h=colormapline(1:1:256,LS(:,1),,spectrum); set(h,'linewidth',2); title ('L* plot for natural spectrum colormap','Color','k','FontSize',12);
If you have a Matlab figure already open and want to use the code above with the color palette for that figure, add this command at the top:
mycmap = colormap;
and replace spectrum with mycmap in the rest of the code.
In the next post I will look at the rainbow as it is seen by people with color vision deficiencies, then I will show what I have done to fix it. Stay tuned!
Related posts (MyCarta)
Related topics (external)
Color Oracle – color vision deficiency simulation – stand alone (Window, Mac and Linux)
Dichromacy – color vision deficiency simulation – open source plugin for ImageJ
Vischeck – color vision deficiency simulation – plugin for ImageJ and Photoshop (Windows and Linux)
NASA’s teaching resources for grades 6-9: What’s the Frequency, Roy G. Biv?
 Rogowitz, B.E., and Treinish, L.A., – Why Should Engineers and Scientists Be Worried About Color? http://www.research.ibm.com/people/l/lloydt/color/color.HTM
 Light, A. and Bartlein, P.J. (2004) – The end of the rainbow? Color schemes for improved data graphics – EOS Transactions of the American Geophysical Union 85 (40) – Reprint of Article with Replies http://geography.uoregon.edu/datagraphics/EOS/Light-and-Bartlein.pdf
 Color for the Sciences, Jan J. Koenderink, 2010 MIT Press http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=12284
 Borland, D. and Taylor, R. M. II (2007) – Rainbow Color Map (Still) Considered Harmful – Computer Graphics and Applications, Vol. 27, No. 2 (IEEE) http://www.jwave.vt.edu/~rkriz/Projects/create_color_table/color_07.pdf
 Borkin, M.A., et al. (2011) – Evaluation of Artery Visualizations for Heart Disease Diagnosis – Transactions on Visualization and Computer Graphics, Vol. 17, No. 12 (IEEE) http://gvi.seas.harvard.edu/sites/all/files/borkin-InfoVis2011_camera-ready.pdf