I want to use the colormap "viridis" (http://bids.github.io/colormap/), and I won't be updating to the development version 1.5 quite yet. Thus, I have downloaded colormaps.py
from https://github.com/BIDS/colormap. Unfortunately, I'm not able to make it work. This is what I do:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import colormaps as cmaps
img=mpimg.imread('stinkbug.png')
lum_img = np.flipud(img[:,:,0])
plt.set_cmap(cmaps.viridis)
imgplot = plt.pcolormesh(lum_img)
This gives me a ValueError
, the traceback ending with,
ValueError: Colormap viridis is not recognized. Possible values are: Spectral, summer, coolwarm, ...
(And then the complete list of originally installed colormaps.)
Any thoughts on how to fix this issue?
Download the colormaps.py from here,then:
Done!
To set
viridis
as your colormap usingset_cmap
, you must register it first:Rather than using
set_cmap
, which requires amatplotlib.colors.Colormap
instance, you can set thecmap
directly in thepcolormesh
call(
cmaps.viridis
is amatplotlib.colors.ListedColormap
)What I did is to just copy the
from https://github.com/BIDS/colormap/blob/master/colormaps.py
and add: