Skip to content
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 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 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