Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate implicit creation of colormaps in register_cmap() #15875

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

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 7 doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ Case-insensitive capstyles and joinstyles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please pass capstyles ("miter", "round", "bevel") and joinstyles ("butt",
"round", "projecting") as lowercase.

Passing raw data to ``register_cmap()``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Passing raw data via parameters *data* and *lut* to `.register_cmap()` is
deprecated. Instead, explicitly create a `.LinearSegmentedColormap` and pass
it via the *cmap* parameter:
``register_cmap(cmap=LinearSegmentedColormap(name, data, lut))``.
13 changes: 11 additions & 2 deletions 13 lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
instance. The *name* is optional; if absent, the name will
be the :attr:`~matplotlib.colors.Colormap.name` attribute of the *cmap*.

In the second case, the three arguments are passed to
The second case is deprecated. Here, the three arguments are passed to
the :class:`~matplotlib.colors.LinearSegmentedColormap` initializer,
and the resulting colormap is registered.
and the resulting colormap is registered. Instead of this implicit
colormap creation, create a `.LinearSegmentedColormap` and use the first
case: ``register_cmap(cmap=LinearSegmentedColormap(name, data, lut))``.
"""
cbook._check_isinstance((str, None), name=name)
if name is None:
Expand All @@ -103,6 +105,13 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
if isinstance(cmap, colors.Colormap):
cmap_d[name] = cmap
return
if lut is not None or data is not None:
cbook.warn_deprecated(
"3.3",
message="Passing raw data via parameters data and lut to "
"register_cmap() is deprecated. Instead use: "
"register_cmap("
"cmap=LinearSegmentedColormap(name, data, lut))")
# For the remainder, let exceptions propagate.
if lut is None:
lut = mpl.rcParams['image.lut']
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.