[ENH]: Default `matplotlib.colormaps[None]` to call `matplotlib.colormaps[matplotlib.rcParams['image.cmap']]`? · Issue #23981 · matplotlib/matplotlib · GitHub
Skip to content

[ENH]: Default matplotlib.colormaps[None] to call matplotlib.colormaps[matplotlib.rcParams['image.cmap']]? #23981

Description

@mroeschke

Problem

While addressing the matplotlib.cm.get_cmap deprecation in 3.6:

PendingDeprecationWarning: The get_cmap function will be deprecated in a future version. Use ``matplotlib.colormaps[name]`` instead.

I noticed that None isn't directly migrate-able

In [1]: import matplotlib

In [2]: matplotlib.cm.get_cmap(None)
Out[2]: <matplotlib.colors.ListedColormap at 0x11e609e20>

In [3]: matplotlib.colormaps[None]
KeyError: 'None is not a known colormap name'

Proposed solution

It appears from the source that get_cmap(None) defaults to matplotlib.rcParams['image.cmap'] so it would be nice if colormaps[None] could default to that as well.

Otherwise, it would be nice if this was better documented.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions