Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More perceptually uniform colormaps?

I am an advocate of using perceptually uniform colormaps when plotting scientific data as grayscale images and applying false colorings. I don't know who invented these, but these colormaps are fantastic and I would not use anything else.

Anyways to be honest, I've gotten a bit bored of the 5 colormaps (viridis, plasma, inferno, magma, cividis) which have been implemented in many popular graphing softwares (R-ggplot, python-matplotlib, matlab, JMP, etc.). I'm sure some of you also feel the same monotony...

So in addition to those 5 colormaps, what are some other colormaps which are perceptually uniform?

BONUS: Is there some algorithm to derive colormaps with perceptually uniform qualities (maybe not since color perception has a psychological aspect)? but if so, what is it?

Some examples & refs: https://matplotlib.org/tutorials/colors/colormaps.html https://matplotlib.org/tutorials/colors/colormaps.html

https://www.youtube.com/watch?v=xAoljeRJ3lU

like image 525
Kardo Paska Avatar asked Apr 28 '20 18:04

Kardo Paska


People also ask

What is a perceptually uniform Colormaps?

Plasma is a perceptually uniform color map with monotonically increasing luminance and a pleasant smooth arc through blue, purple, and yellow hues. Plasma is one of the matplotlib color maps developed by Stéfan van der Walt and Nathaniel Smith.

What is perceptually uniform?

The concept is explained here — if a color space is perceptually uniform, it means that a change of length x in any direction of the color space would be perceived by a human as the same change.

How do I choose a colormap?

Researchers have found that the human brain perceives changes in the lightness parameter as changes in the data much better than, for example, changes in hue. Therefore, colormaps which have monotonically increasing lightness through the colormap will be better interpreted by the viewer.


3 Answers

If you follow this page: http://bids.github.io/colormap/, you will find all the details required to produce Viridis, Magma, Inferno and Plasma. All the details are too long to enumerate as an answer but using the aforementioned page and viscm, you can regenerate them and some more interactively.

Alternatively, and using Colour:

import colour
import numpy as np

CAM16UCS = colour.convert(['#ff0000', '#00ff00'], 'Hexadecimal', 'CAM16UCS')
gradient = colour.utilities.lerp(
    CAM16UCS[0][np.newaxis],
    CAM16UCS[1][np.newaxis],
    np.linspace(0, 1, 20)[..., np.newaxis])
RGB = colour.convert(gradient, 'CAM16UCS', 'Output-Referred RGB')

colour.plotting.plot_multi_colour_swatches(
    [colour.plotting.ColourSwatch(RGB=np.clip(x, 0, 1)) for x in RGB])

print(colour.convert(RGB, 'Output-Referred RGB', 'Hexadecimal'))

['#fe0000' '#fb3209' '#f74811' '#f35918' '#ef671e' '#ea7423' '#e67f28'
 '#e18a2c' '#dc9430' '#d79e34' '#d1a738' '#cbb03b' '#c4b93d' '#bcc23e'
 '#b2cc3d' '#a6d53a' '#97df36' '#82e92e' '#62f321' '#00ff00']

PUG

Note that the two boundary colours are given as hexadecimal values but you could obviously choose any relevant colourspace. Likewise, CAM16 could be swapped for JzAzBz or alike.

You can try that online with this Google Colab notebook.

like image 70
Kel Solaar Avatar answered Oct 14 '22 23:10

Kel Solaar


Bit late I suppose, but my CMasher package provides a large collection (I think it is 42 at the time of writing) of scientific colormaps that are all perceptually uniform sequential. Below is an overview of all colormaps that are currently available in CMasher at the time of writing. CMasher colormap overview

In the online documentation, I describe every single colormap individually; discuss the main ways to improve colormap usage and much more. It also provides a collection of utility functions that can be used to manipulate colormaps in various ways.

like image 24
1313e Avatar answered Oct 15 '22 00:10

1313e


For deriving colormaps with perceptually uniform qualities, please refer to this answer.

The following python packages offer (perceptually uniform) colormaps:

  • CMasher
  • colorcet
    • also includes maps for the color blind
    • available for python
    • and more
  • cmocean
like image 43
Mark Loyman Avatar answered Oct 15 '22 00:10

Mark Loyman