Skip to content

Commit cdbae22

Browse files
committed
API: remove implicit colormap generation in register_cmap
This was deprecated in 3.3 via matplotlib#15875
1 parent f7e52e2 commit cdbae22

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

‎lib/matplotlib/cm.py‎

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,27 @@ def _warn_deprecated(self):
101101
# Continue with definitions ...
102102

103103

104-
def register_cmap(name=None, cmap=None, data=None, lut=None):
104+
def register_cmap(name=None, cmap=None):
105105
"""
106106
Add a colormap to the set recognized by :func:`get_cmap`.
107107
108-
It can be used in two ways::
108+
Register a new colormap to be accessed by name ::
109109
110-
register_cmap(name='swirly', cmap=swirly_cmap)
110+
LinearSegmentedColormap('swirly', data, lut)
111+
register_cmap(cmap=swirly_cmap)
111112
112-
register_cmap(name='choppy', data=choppydata, lut=128)
113+
Parameters
114+
----------
115+
name : str, optional
116+
The name that can be used in :func:`get_cmap` or :rc:`image.cmap`
117+
118+
If absent, the name will be the :attr:`~matplotlib.colors.Colormap.name`
119+
attribute of the *cmap*.
113120
114-
In the first case, *cmap* must be a :class:`matplotlib.colors.Colormap`
115-
instance. The *name* is optional; if absent, the name will
116-
be the :attr:`~matplotlib.colors.Colormap.name` attribute of the *cmap*.
121+
cmap : matplotlib.colors.Colormap
122+
Despite being the second argument and having a default value, this
123+
is a required argument.
117124
118-
The second case is deprecated. Here, the three arguments are passed to
119-
the :class:`~matplotlib.colors.LinearSegmentedColormap` initializer,
120-
and the resulting colormap is registered. Instead of this implicit
121-
colormap creation, create a `.LinearSegmentedColormap` and use the first
122-
case: ``register_cmap(cmap=LinearSegmentedColormap(name, data, lut))``.
123125
124126
Notes
125127
-----
@@ -146,19 +148,6 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
146148
cmap._global = True
147149
_cmap_registry[name] = cmap
148150
return
149-
if lut is not None or data is not None:
150-
cbook.warn_deprecated(
151-
"3.3",
152-
message="Passing raw data via parameters data and lut to "
153-
"register_cmap() is deprecated since %(since)s and will "
154-
"become an error %(removal)s. Instead use: register_cmap("
155-
"cmap=LinearSegmentedColormap(name, data, lut))")
156-
# For the remainder, let exceptions propagate.
157-
if lut is None:
158-
lut = mpl.rcParams['image.lut']
159-
cmap = colors.LinearSegmentedColormap(name, data, lut)
160-
cmap._global = True
161-
_cmap_registry[name] = cmap
162151

163152

164153
def get_cmap(name=None, lut=None):

0 commit comments

Comments
 (0)