You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New colormaps are not included in the plt.cm.datad dictionary. #5202
The new colormaps (viridis, magma, plasma, and inferno) do not appear in the plt.cm.datad dictionary.
C:\>python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib as mpl
>>> import matplotlib.pyplot as plt
>>> print(mpl.__version__)
1.5.0rc2
>>> 'jet' in plt.cm.datad
True
>>> 'viridis' in plt.cm.datad
False
>>> s1 = set(plt.colormaps())
>>> s2 = set(plt.cm.datad.keys())
>>> sorted(s1 - s2)
['inferno', 'inferno_r', 'magma', 'magma_r', 'plasma', 'plasma_r', 'viridis', 'viridis_r']
>>> mpl.cm.datad is plt.cm.datad
True
>>>
As a result, the pylab_examples example code demo_bboximage.py will not include the new color maps, and the documentation for matplotlib.cm.get_cmap(name=None, Lut=None) is no longer correct. It states that "name must be a standard mpl colormap name with a corresponding data dictionary in datad." In fact, map = mpl.cm.get_cmap('viridis') works just fine despite the fact that 'viridis' has no entry in datad.
Suggested fix:
Add the new colormaps to plt.cm.datad.
Alternate fix:
Update demo_bboximage.py to include the new colormaps.
Update the documentation for matplotlib.cm.get_cmap().
Good catch.
Your alternate fix is the way to go. These maps are implemented using a more compact format than would be the case if they were in datad; the same could be done with many of the existing mpl colormaps.
Activity
efiring commentedon Oct 7, 2015
Good catch.
Your alternate fix is the way to go. These maps are implemented using a more compact format than would be the case if they were in datad; the same could be done with many of the existing mpl colormaps.
QuLogic commentedon Oct 8, 2015
Maybe fixed by, or should be added to, #4965.
Fix matplotlib#5202. Make new colormaps full-fledged citizens