FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: `matplotlib.cm.get_cmap()` missing · Issue #28349 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: matplotlib.cm.get_cmap() missing #28349

Description

Bug summary

As of matplotlib v3.9, it appears that matplotlib.cm.get_cmap() is missing. It is still available on matplotlib.pyplot.get_cmap(), though.

matplotlib.cm.get_cmap() is still shown in the documentation and I would be surprised if this change was made without some kind of deprecation warning.

Code for reproduction

In [1]: from matplotlib import pyplot, cm

In [2]: pyplot.get_cmap('gray')
Out[2]: <matplotlib.colors.LinearSegmentedColormap at 0x7f6b2c7303d0>

In [3]: cm.get_cmap('gray')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 cm.get_cmap('gray')

AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'

Actual outcome


AttributeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 cm.get_cmap('gray')

AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'

Expected outcome

Should return the gray colormap.

Additional information

This works in matplotlib <3.9 and is still shown in the documentation. It is kind of odd that this function is available from two locations, though.

Operating system

Any

Matplotlib Version

3.9.0

Matplotlib Backend

agg

Python version

3.11.9

Jupyter version

No response

Installation

pip

Activity

  1. greglucas commented on Jun 5, 2024

    Contributor

    Duplicate of #28317

    This was marked with a deprecation and in 3.8.4 I get the following:

    >>> matplotlib.cm.get_cmap("gray")
    <stdin>:1: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.

    Edit: Also note that the get_cmap() is a method on ColormapRegistry there, not at the module level. It isn't super obvious when first looking at the page.

  2. tacaswell commented on Jun 6, 2024

    Member

    We are seeing multiple reports that the warnings in 3.8 were not seen. We should sort out why and consider putting the API in a micro release with a more visible warning (at maybe a custom AttributeError that gives more context?).

  3. added a commit that references this issue on Mar 29, 2025
  4. added a commit that references this issue on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL