Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
@mroeschke

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions