Latest Note

I've ordered notes thematically, not chronologically. The latest note is an alternative scheme for qualitative data.

Colour Schemes

To make graphics with your scientific results as clear as possible, it is handy to have a palette of colours that are:

  • distinct for all people, including colour-blind readers;
  • distinct from black and white;
  • distinct on screen and paper;
  • still match well together.

To optimize the palette, I have used mathematical descriptions of colour differences and colour-blind vision. The result is shown on the right. A technote describes this and an alternative palette, the best selections of any number of colours up to 12, a selection optimized for black and white printers, example figures and background information.

The palette is meant for qualitative data, where magnitude differences are not relevant. This includes text and lines. Colour schemes for ordered data can be found at the ColorBrewer website. Some of the best are also described in the technote. The site warns against the use of rainbow schemes (see also the example below), but they remain popular and they can still be reasonably effective for colour-blind people if designed properly. It should not come as a surprise that my technote also includes several good rainbow schemes.

In version 2 of the technote I have redesigned all colour schemes. Now any printer that conforms to international standard ISO 12647-2 can reproduce all colours. On 29 December 2012, I have updated the section on rainbow schemes.

Time moves on and I have devised alternative schemes that are given in sections below. The technote and code below have not been updated yet.

For IDL users, I have produced routines that set the colour palette to one of the schemes above. The keyword N_COLORS can be set to the number of different colours needed, default is the maximum number. See the header for more information. The routines are:


For gnuplot users, Tim van Werkhoven has written example scripts with:

gnuplot schemestwo schemes with either 4 colours that also work well on a black and white printer, or up to 8 colours in best order, with results this and this;

gnuplot gradientsthree smooth gradients for ordered data, with results that look like this, this and this.

For python users, he has also written example scripts with:

python gradientsthree smooth gradients for ordered data, with results that look like this, this and this.

python schemesPieter van der Meer has written a module for the scheme of distinct colours.

Alternative Scheme for Qualitative Data

Better distinct paletteMost of the time, six colours plus grey are enough to map qualitative data. In these cases, I prefer slightly brighter colours, including a medium dark blue instead of the very dark blue in the palette at top right. This new palette of colour-blind safe, print-friendly colours I now use almost always for qualitative data. For 5 or more colours, I use them in clockwise order from bottom left: blue, cyan, green, yellow, red, pink, grey (and black). For 4 or fewer colours, I switch cyan and red: blue, red, green, yellow. But I deviate when plot lines have a logical colour association, e.g. cloud fraction above oceans blue and above desert yellow.

Alternative Schemes for Sequential Data

Yellow-orange-brown paletteNormal rainbow paletteThe yellow-orange-brown scheme above (taken from ColorBrewer) is a good sequential scheme, for ordered data from low to high, shown with the most distinct grey for data gaps (not for extreme values). However, I often prefer a rainbow scheme to read the value in a map more easily. The technote gives the rainbow scheme above. There you can also find formulas for the interpolated, smooth versions of both schemes. I've used this rainbow scheme a lot, but the pink end is rather dark and sometimes a larger range of colours is needed. Therefore I've tweaked and extended the rainbow scheme.Extended rainbow palette It includes the main rainbow from pink to red, with two extensions from pink to off-white at the low end and from red to brown at the high end. They form 4 schemes for maps: 1) pink-red, 2) pink-brown, 3) white-brown, 4) white-red. All colours of a given scheme should be used, in a linear interpolation to form a smooth scheme. The steps are small enough for that. It is tempting to use scheme 3 (the largest) by default, but I use the extension to off-white only when large map areas have the lowest value (to avoid a mostly pink map) and I use the extension to brown only when small map areas have the highest value (to avoid a mostly dark map). For colour-blind people, the light pinks and light blues should not be mixed much. That is another reason to use the extension to off-white with care.

A rainbow scheme with many discrete steps is given below, even though experts warn against many steps, rainbows and banded schemes. It is based on the temperature map of the weather forecast in newspaper de Volkskrant (paid version), tweaked to make the colours more distinct and reasonably colour-blind safe. It doesn't remain colour-blind safe when the colours are interpolated. I've used this scheme in the note on map making. I also give another version with more but slightly less distinct steps. Again, the grey given at the end is for data gaps and is not part of the normal scheme.Short bright rainbow paletteLong bright rainbow palette

Alternative Schemes for Diverging Data

Red-blue palettePurple-green paletteHere are two diverging schemes, for ordered data between two extremes where the midpoint is important. I use them for differences between data sets that are or should be mostly the same. This means most of the map will be light grey: a bit dull, but any deviation stands out. This colour is not completely white to make it slightly distinct from a white background. It is handy to have more than one scheme. For example, when I produce difference maps for CO and methane, each molecule has its own scheme, so it isn't necessary to read the legend to know which molecule is plotted. For data gaps I use the light yellow, which is clearly different from the four main hues and by being light, it doesn't draw too much attention. A shade of grey would need to be rather dark to be distinct, making a data gap look like an area with a large difference.

These schemes are taken from the ColorBrewer website, but one of the green shades has been tweaked to make it printable (by a ISO 12647-2 printer). You could construct similar schemes simply by scaling the colour coordinates linearly e.g. from blue to white to red, but the schemes above have subtle hue changes to make the colours more distinct and the schemes more attractive. Each scheme separately is colour-blind safe, but they look similar in colour-blind vision. Therefore, if you use both in the same document, don't reverse the direction in one of them. ColorBrewer also has a darker shade of each of the four hues, but they are too dark and similar to be used in practice.

Scheme for Marking Text

Marking paletteThis is a scheme for marking text: use the light colours for the background of black text or the dark colours for the text on a white background. By keeping the background light or the text dark, respectively, the text is still easy to read when a large block has been marked. The colours should be distinct if you are colour-blind, but I would only use dark red to mark a block of text, not just one word.

Colour Vision Test

Almost all people with reduced colour vision are either red-blind or green-blind. This means the cone cells in the retina that are sensitive to long or medium wavelengths have their response shifted partially or completely to that of the opposite type. The readable text in the image below is the colour-vision diagnosis of the reader. It is not a puzzle: there is no hidden message that requires much effort to see. The clarity of the text is not important, only whether it is readable at all. It works well, but please do not make life-changing decisions based only on this test. Colour vision test

Another Alternative Colour Scheme

Bright colour paletteLike the palette at top right, this one consists of colour-blind safe, print-friendly colours for qualitative data, but it contains brighter colours, which look good on screen. Data gaps can be indicated with light grey DDDDDD (221, 221, 221). This palette is a bit less colour-blind safe than the top one and note that thin lines of hard yellow on a white background may be difficult to see. I prefer the alternative scheme for qualitative data above.

Good and Bad Colour Schemes Compared

The following figures show the true physical figure of the Earth using two colour schemes: at the top the sunset scheme defined here, at the bottom a traditional rainbow scheme as defined by many programs (e.g. IDL).

Good colours Bad colours

Most rainbow schemes contain bands of almost constant hue with sharp transitions in-between, which are perceived as jumps in the data. In this example large areas are green without features, while for example the yellow line in northern Australia implies a sudden change that does not exist in reality. The oceanic trench at top right can be seen over the whole length in the top figure, while it becomes difficult to see near Japan in the bottom figure. This shows that it is more important that a scheme is smooth than that it contains many colours. In addition, colour-blind people have difficulty distinguishing some colours of the rainbow. In the bottom figure, the yellow spot in the middle of the Sahara is not visible in red-blind vision, making the green areas effectively even larger than they are in normal vision. Last but not least, the sunset scheme emphasizes more clearly the average (light colours) and the extremes (dark colours of contrasting hues).

In this context the meaning of the figures is not really important, but if you're interested: they show the distance between the WGS84 ellipsoid and the geoid calculated with the EGM96 gravity model. Click on the images for larger versions.

Map Making

Currently I produce maps in two steps. First, I perform the analysis in whatever program and export the data as a particular type of ASCII table. Then, I apply a colour look-up table to the data and export the result as a PNG file. This way, I don't have to redo the analysis if I want a different colour scale, e.g. to emphasize a different value range. The second step is performed on the command line with the command 'convert' of ImageMagick, a free, cross-platform and open-source program suite for image manipulation.

The data is exported to a plain portable graymap (PGM) file, which is an ASCII file starting with 'P2 w h 65535 ', where w is the width and h the height of the map, followed by a list of integers in the range 0 to (in my case) 65535 with a space or newline between the values. Because the width and height are given, the spaces and newlines can be put wherever you like. The 'P2' identifies the file as a PGM file. I scale the data so all values are in the range 0-65532 (but you don't have to fill this whole range). The other possible values are reserved: 65533 for bad data, 65534 for text and lines and 65535 for no data (e.g. outside the projection of the world).

The colour look-up table (clut) is exported to a plain portable pixmap (PPM) file, which is an ASCII file starting with 'P3 1 n 255 ', where n is the number of colours, followed by a list of RGB coordinates of the colours as integers in the range 0-255 with a space or newline between the values. I don't use perfectly white, because that may become transparent later on.

Now the image can be produced. The data is stored in input.pgm, the clut in clut.ppm and the image should be output.png. If none of the 3 reserved values are used, then the command is: convert input.pgm -level 0,65532 clut.ppm -interpolate integer -clut -depth 8 output.png To spread all available colours over the data range [b,w], change the level option to '-level b,w' (values outside this range will have the first or last colour). To interpolate the colours (for a smooth gradient instead of discrete steps), remove option '-interpolate integer'. If any of the reserved values are used, then the command is: convert input.pgm \( +clone -level 0,65532 clut.ppm -interpolate integer -clut \) \( -clone 0 -black-threshold 65533 -transparent black -fill \#000 -opaque \#FFFEFFFEFFFE -fill \#777 -opaque \#FFFDFFFDFFFD \) -flatten -transparent white -depth 8 output.png Here I have assumed that text should be black (#000), bad data grey (#777) and areas without data transparent. If you want a white instead of a transparent background, remove option '-transparent white'. To treat bad data as background, set it to #FFF. The command above is given in Linux syntax; in Windows, remove all backslashes.

An example: given a map of the albedo at 750 nm including the legend (input.pgm) and a list of colours (clut.ppm), the output of the command above (with option -level 0,9999) is this image.Output map

If the background is transparent, for clarity a white outline can be added around the objects: convert output.png -bordercolor none -border 1 \( +clone -channel A -morphology edgeout square +channel +level-colors white \) -compose dstover -composite output_outlined.pngOutput map with outline

SRON PowerPoint Template

SRON templateThe SRON style for presentations has a dark grey background. I have produced a design template for PowerPoint 2003 or earlier and a theme for PowerPoint 2007 or later with a palette including the regular colours white (for titles), light yellow (for normal text) and orange (for stressed text), but also three extra colours that are suitable for use with beamers: the light blue of the footer and shades of green and red that work well. In other programs like Impress, the colour codes have to be copied manually from Figure 6.

SRON template with white backgroundAlternative version of the theme with a white background on all pages except the title page, either standard (4:3) or wide (16:9).

SRON LaTeX Template

The current official style of SRON reports, technotes, etc. can also be achieved in LaTeX and pdfLaTeX. Two or three files are needed:

  • sron.cls, the class file;
  • srontemplate.tex, an example and starting point for new documents;
  • pict2e.sty, an update of a standard package, only needed in Debian 5 (lenny).

Running (pdf)LaTeX on srontemplate.tex should give a result that looks like this. Under Debian, you may need to execute first (once) the command "sudo apt-get install texlive-fonts-extra".