Colormaps#

The various colormaps are available:

  • as attributes of the tol_colors module (eg tc.sunset)

  • in the dictionary tol_colors.colormaps (eg tc.colormaps["sunset"]). This returns copies that you can modify safely.

  • registered in matplotlib with the prefix “tol.” (eg plt.imshow(..., cmap="tol.sunset"))

Each colormap has a reversed variant directly available with the suffix “_r” (eg tc.sunset_r)

Tip

Click on a colormap to show its viscm evaluation in a new tab.

The colormaps were created by linear interpolation of carefully chosen colors. For most colormaps, a discrete variant is available by adding “_discrete” to the colormap name (eg tc.sunset_discrete). To obtain discrete colormaps with a different number of colors it is always possible to resample a continuous colormap with:

tc.sunset.resampled(n_colors)

However do not resample the rainbow colormaps, instead use the dedicated function.

Diverging#

Important

The four diverging schemes look similar in color-blind vision, so if more than one is used, do not reverse the direction in one of them.

Sunset#

The scheme is related to the Color-Brewer RdYlBu scheme, but with darker central colors and made more symmetric. Sunset is designed for situations where bad data have to be shown white.

Sunset colormap

Nightfall#

The scheme is inspired py the Color-Brewer PuBuGn and YlOrRd schemes. Like Sunset, it is designed for situations where bad data have to be shown white but with more hues. The discrete variant uses less colors than the linear definition.

nightfall colormap

BuRd#

This is the reversed and tweaked Color-Brewer RdBu scheme. Bad data is #FFEE99.

Blue-Red colormap

PRGn#

This is the Color-Brewer PRGn scheme, with green shifted to make it print-friendly. Bad data is #FFEE99.

Purple-Green colormap

Sequential#

YlOrBr#

This is the Color-Brewer YlOrBr scheme, with orange shifted to make it print-friendly. Bad data is #888888.

Yellow-Orange-Brown colormap

The variant WhOrBr replaces the first color (pale yellow) with pure white:

White-Orange-Brown colormap

Iridescent#

A colormap with linearly varying luminance that also works in colourblind vision. Bad data is #999999. It is not directly available as a discrete colormap.

iridescent colormap

Incandescent#

A colormap with linearly varying luminance that also works in colourblind vision, but is not print-friendly. Bad data is #888888. It is not directly available as a discrete colormap. The pale cyan #CEFFFF is almost white in red-blind vision.

incandescent colormap

Linear rainbow#

There are many pitfalls to using a continuous rainbow colormap for ordered data:

  • The spectral order of visible light carries no inherent magnitude message. However, a rainbow provides a scheme with many colors, showing subtle effects in the data clearer or making it easier to read the value in a map. There are also cases where it is preferred to have a colormap that does not have pale colors at the low end or middle of the range.

  • Most rainbow schemes contain bands of almost constant hue with sharp transitions between them, which are perceived as jumps in the data. This can be avoided with careful design.

  • Colorblind people have difficulty distinguishing some colors of the rainbow. This can be taken into account in the design.

Important

The following colormaps should only be used interpolated. For a discrete rainbow colormap, see the next section.

rainbow_WhBr#

The full rainbow colormap. It is also available under the alias rainbow.

rainbow colormap (white to brown)

rainbow_WhRd#

Often it is better to use only a limited range of the rainbow colors. rainbow_WhRd stops at red and avoid the browns, which is useful when the highest values (towards brown) occur often in the data.

rainbow colormap (white to red)

rainbow_PuBr#

Often it is better to use only a limited range of the rainbow colors. rainbow_PuBr starts at purple and avoids the light purple, which is useful when the lowest values (towards white) occur often in the data. It is preferable to avoid mixing light purples and light blues too much for colorblind people.

rainbow colormap (purple to brown)

rainbow_PuRd#

Often it is better to use only a limited range of the rainbow colors. rainbow_PuRd avoids both ends, which is useful when the lowest and highest values occur often in the data.

rainbow colormap (purple to red)

Discrete rainbow#

A function is provided to return a discrete rainbow colormap with a given number of colors. That number can vary between 1 and 23 (included). The colors are obtained by selecting among 23 statically defined colors. The results are displayed below.

Bad data is marked with white by default, except when using 23 colors where it will be marked with grey #777777.

tol_colors.rainbow_discrete(n_colors: int = 22) ListedColormap

Discrete rainbow colormaps.

The number of colors can vary between 1 and 23 (included).

discrete rainbow colormap

CVD Simulations#

Below are simulations of all the colormaps for total deuteranomaly and protanomaly. Done using the colorspacious package, using the model from Machado, Oliveira and Fernandes (DOI: 10.1109/TVCG.2009.113).

_images/cmaps_cvd.svg