Skip to content

New colormaps are not included in the plt.cm.datad dictionary. #5202

Closed
@japagetw

Description

@japagetw

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().

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions