Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
japagetw opened this issue Oct 6, 2015 · 2 comments
Closed

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

japagetw opened this issue Oct 6, 2015 · 2 comments

Comments

@japagetw
Copy link

japagetw commented Oct 6, 2015

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().
@tacaswell tacaswell added this to the next point release (1.5.0) milestone Oct 6, 2015
@efiring
Copy link
Member

efiring commented 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
Copy link
Member

QuLogic commented Oct 8, 2015

Maybe fixed by, or should be added to, #4965.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants