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?
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
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"].
@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.
Activity
soma2000-lang commented on Jan 30, 2022
@mwaskom I am working on this.
soma2000-lang commented on Feb 3, 2022
@mwaskom I could not find the documentation where this warning is mentioned .Please help.
greglucas commented on Feb 3, 2022
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 commented on 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 commented on Feb 4, 2022
Ok.