+44 (0)1424 225228 sales@torrscientific.co.uk

Visualising data with colour maps

 

It is not uncommon in science to have a dataset consisting of a set of measurements, each with (x, y) coordinates for the position in two‑dimensional space at which the measurement was performed. A convenient way to visualize the content of such a dataset is often to represent the values (measured data) with colours that are mapped onto a representative two‑dimensional (x, y) space. An example of this is where colours representing surface height are mapped in two dimensions (Figure 1).

Figure 1: A spatial colour map (left) of surface height data, acquired using a white-light interferometer, with a profile plot (bottom) defined by the superimposed straight line on the colour map. The same data are rendered as a three-dimensional plot (right). Note that in both the profile plots and the three dimensional plot the vertical scale is greatly exaggerated relative to the horizontal.

Figure 1: A spatial colour map (left) of surface height data, acquired using a white-light interferometer, with a profile plot (bottom) defined by the superimposed straight line on the colour map. The same data are rendered as a three-dimensional plot (right). Note that in both the profile plots and the three dimensional plot the vertical scale is greatly exaggerated relative to the horizontal.

Applications of colour mapping in science

 

Such plots usually sport a legend bar as at bottom left (Figure 1), giving an indication of how the values map to the different colours. The user will often have some control over the top and bottom limits of the scale so that the visual contrast of the plotted image can be adjusted to best display the data of interest. There are many types of dataset that lend themselves to colour mapping in both two‑dimensional and three‑dimensional spaces. These include atomic force microscopy (AFM), transmitted wavefront error (TWE), any form of scanning microscopy, thermal imaging, finite element analysis (FEA), gravimetry and land/sea topography.

 

The rainbow colour scale: Ubiquity and issues

 

The popularity of rainbow (Jet) scales

 

Almost ubiquitous among most of these fields is the colour scale resembling a rainbow (Figure 1), often referred to as Jet. Here we will refer just to rainbow as a catch-all term for all such scales. In a Good Practice Guide from National Physical Laboratory, UK, 42 of 48 graphics showing surface height profiles are rendered in a rainbow scale. Rainbow is the default scale in many instrument control packages, but a quick search of the internet shows that there is something of a backlash against its use for displaying scientific data.

 

Colour order intuition (and misconceptions)

 

Most of us are fairly familiar with the ROYGBIV order of colours in a rainbow. In the context of most plots with a rainbow colour scale, this order represents high to low. In case of doubt, you can always fall back on any of the many mnemonics (in this part of the world, we say Richard of York gave battle in vain). It could be argued that red is intuitively higher than blue by analogy with temperature. There is, however, no obvious reason why, for example, green should be lower than yellow.

 

Perceptual non-uniformities in rainbow scales

 

There is said to be a crock of gold at the end of a rainbow (spoiler alert: this is not true. Rainbows do not have ends). Look instead within the spectrum itself where you will find something: perceptual non-uniformities. In other words, not only is the order of colours not entirely logical, but the brightness does not vary from low to high in any meaningful way. This is most easily seen when the scale is rendered in greyscale (Figure 2).

Figure 2: the Jet rainbow scale used in Matlab (top) with the same scale desaturated (bottom).

Figure 2: the Jet rainbow scale used in Matlab (top) with the same scale desaturated (bottom).

There are two obvious bright regions corresponding to pale blue and yellow, while the blue‑green transition shows little contrast. Rainbow scales can present problems for people with any of the various colour­­­-vision deficiencies.

 

Figure 3: AFM scan from the unpolished face of a synthetic diamond. The quantity depicted is surface height.

Figure 3: AFM scan from the unpolished face of a synthetic diamond. The quantity depicted is surface height.

Alternative colour mapping approaches

Atomic force microscopy (AFM)

 

A technique that tends not to have a rainbow scale is AFM (atomic force microscopy). For whatever reason, AFM traditionally uses a scale that typically goes from near­­‑black to near‑white by way of ever lighter shades of brown (Figure 3). AFM scans very often, though not always, depict a height map from a sample surface.  The higher regions are represented by lighter shades and the lower regions by darker shades.

The dark‑light scheme conveys height very effectively. It seems to work so well with the human vision system that a casual observer might mistake the image for an optical capture as from a digital microscope.

 

Figure 4: a scanning electron micrograph of some grains of sugar. The row of dots at lower right is the 150 µm (0.15 mm) scale bar.

Figure 4: a scanning electron micrograph of some grains of sugar. The row of dots at lower right is the 150 µm (0.15 mm) scale bar.

Scanning electron micrographs (SEMs)

Another rainbow-free image type that is very easily mistaken for a photograph is the scanning electron micrograph (Figure 4). The brightness of each pixel is proportional to the intensity of secondary electrons detected when that position on the sample is hit from above by a scanning electron beam. It is just electrons in and electrons out; light plays no part in the imaging process. But… if there is no light involved, then why can we clearly see brightness and shade on different facets of the grains? The detector that hoovers up and counts the secondary electrons is off to the lower left of the image. Where a surface is facing the detector, more secondary electrons are hoovered up, so the pixels here are brighter. The resulting image appears to be viewed from directly above (the source of the primary‑electron beam) and lit from the lower left (the position of the secondary‑electron detector). The brightness, shade and depth of field give the impression of a monochrome photograph, but in essence, like most other digital image captures, this is just an intensity map.

 

Perceptually uniform colour scales

 

Where a colour scale is designed so that, unlike rainbow, brightness and colour change linearly along the scale, it is described as perceptually uniform. This is arguably the best approach to faithfully representing a dataset visually with a colour map. When perceptually uniform scales are desaturated to leave greyscale, the brightness can be seen to vary smoothly from low to high, making them accessible to people with colour vision deficiencies (Figure 5).

Figure 5: Five perceptually uniform scales and a rainbow scale desaturated to simulate several different colour vision deficiencies.

Figure 5: Five perceptually uniform scales and a rainbow scale desaturated to simulate several different colour vision deficiencies. Graphic from https://doi.org/10.1038/s41467-020-19160-7 under Creative Commons

 

Rainbow vs perceptual scales in image interpretation

 

We have seen some images whose simple colour scales help them to chime nicely with our visual perception. What happens if we try to colour images with a rainbow scale? When the light and dark of an original photo is represented by a perceptually uniform scale, it remains recognizable; when a rainbow scale is used, the perception of the image becomes somewhat mangled (Figure 6).

Figure 6: A greyscale image (centre) reproduced with a rainbow scale (left) and a perceptually uniform scale (right). Photo of Marie Skłodowska-Curie by Henri Manuel.

Figure 6: A greyscale image (centre) reproduced with a rainbow scale (left) and a perceptually uniform scale (right). Photo of Marie Skłodowska-Curie by Henri Manuel. Graphic from https://doi.org/10.1038/s41467-020-19160-7 under Creative Commons

 

Evaluating rainbow: Pros and cons

 

Arguments against rainbow

 

The authors of the paper from which Figures 5 and 6 were taken make an interesting point. When you have the original photo, or prior knowledge of the appearance of Earth, an apple and Madame Curie, then it is obvious that rainbow is not doing a good job. When dealing with scientific data, the luxury of prior knowledge is generally absent, so the extent to which data is usefully represented, or otherwise, is not necessarily apparent.

 

Arguments in favour of rainbow

 

It is far easier to find evidence and arguments criticizing the rainbow than to find the few people who put their heads above the parapet to defend it. In the name of balance, I will pass on some of the arguments in favour of the beleaguered rainbow scale. Firstly, it can look quite visually appealing. That mishmash of colours might tempt a few more punters over for a look at your poster presentation or exhibition stand. Some of the perceptually uniform scales, if we are honest, can make a dataset look a little dull. A slightly more technical slant on this is that detail can be somewhat subdued with the more rigorous scales, especially in the background at the darker end of the scale. Although the low-high-low nature of the rainbow can make it difficult to effortlessly perceive relative magnitudes, there is an extra dimension to it that could be a useful source of extra contrast: hue (colour). If you want to highlight subtle background differences in the dataset, rainbow might give you extra options. One view was that rainbow was OK for everyday use, but not for publication.

 

New developments: The Turbo colour scale

 

What Turbo offers

Figure 7: Turbo scale (top) with the traditional Jet scale (bottom).

Figure 7: Turbo scale (top) with the traditional Jet scale (bottom).

Google Research released an improved rainbow scale called Turbo (Figure 7). It transitions more smoothly than Jet and lacks the central bright bands. The creators claim that it performs well for many colour‑vision deficiencies but not for total colour blindness. It does not claim to be perceptually uniform, but it does have what might be called perceptual symmetry: the lightest portion (green) is dead centre, with blue at one end and yellow through red at the other.

 

Turbo as a divergent scale

 

Its creators say that this means it can be used as a divergent scale. A divergent scale typically has a central hue with two symmetrical but different hues stretching out to the ends. I have used a divergent scale (red-white-blue) in finite element analysis (FEA) to display compressive stress in blue and tensile stress in red, with stress-free regions being white. This needs a custom setup in our Mecway software, but Turbo is available so might be worth a try for this purpose.

 

Choosing the right colour scale

 

Consider your goals

 

I will conclude by suggesting that you need to give some thought as to what you want to show with your graphical data display. For a faithful representation of the relative magnitude of the data, choose a perceptually uniform scale. If you are less concerned with this and want to have a bunch of pretty colours, you might choose a rainbow, preferably one like Turbo. To display values that span in two opposite directions from a central value such as zero, go for a divergent scale. To emphasize or highlight a particular feature of your dataset, choose the scheme that best achieves this.

 

Final thoughts and a disclaimer

 

That last suggestion works also if you are being devious and want to lead or deceive with what you show for the purposes of blagging some funding or equipment, but we at Torr Scientific know that you are better than that. Finally, a brief disclaimer: the determined reader could probably find old examples of my own work where the rainbow has been inappropriately used. In case you do, feel free to inwardly judge (as would I), but let’s keep it among ourselves.