pythonmatplotlibggplot2colorscolormap

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


Solution

  • 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.algebra.lerp(
        np.linspace(0, 1, 20)[..., np.newaxis],
        CAM16UCS[0][np.newaxis],
        CAM16UCS[1][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.