Skip to content

[Doc]: Deprecation note in get_cmap is non-actionable #22362

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

Closed
mwaskom opened this issue Jan 30, 2022 · 5 comments · Fixed by #22396
Closed

[Doc]: Deprecation note in get_cmap is non-actionable #22362

mwaskom opened this issue Jan 30, 2022 · 5 comments · Fixed by #22396

Comments

@mwaskom
Copy link

mwaskom commented Jan 30, 2022

Documentation Link

Docstring of mpl.cm.get_cmap

Problem

There is a note that says:

Notes
-----
Currently, this returns the global colormap object, which is deprecated.
In Matplotlib 3.5, you will no longer be able to modify the global
colormaps in-place.

This is not clear about what is deprecated or how users should update. Will it start returning a copy? Will it start returning an immutable object? Should users be using a different function?

Suggested improvement

No response

Matplotlib Version

3.5.1

@soma2000-lang
Copy link

@mwaskom I am working on this.

@soma2000-lang
Copy link

@mwaskom I could not find the documentation where this warning is mentioned .Please help.

@greglucas
Copy link
Contributor

This note is going to be removed for 3.6, so the documentation update would be on the 3.5.x branch. See this PR for the locations of the various pieces of code surrounding this note: #22298

References to a few other issues/PRs that this has stemmed from: #20853, #20853, #19766, #16991

The previous versions of Matplotlib would return the same object every time, which caused issues with changing a mutable state for future access of colormaps. In 3.6+ get_cmap() will return a copy of the colormap with each request. If you weren't getting warnings/errors about "modifying the global state of a colormap" within code, then there shouldn't be any updates necessary.

matplotlib.cm.get_cmap() is still available and there is now a new ColormapRegistry that lives at matplotlib.colormaps which can be used like a dictionary matplotlib.colormaps["viridis"].

@jklymak
Copy link
Member

jklymak commented Feb 3, 2022

@soma2000-lang Thanks for the willingness to help, but this is pretty subtle, and I think we need someone who understands those subtleties to fix the message.

@soma2000-lang
Copy link

Ok.

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

Successfully merging a pull request may close this issue.

4 participants