Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7524ced

Browse files
committed
Deprecate implicit creation of colormaps in register_cmap()
1 parentaa18f5a commit7524ced

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

‎doc/api/next_api_changes/deprecations.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ PDF and PS character tracking internals
4747
The ``used_characters`` attribute and ``track_characters`` and
4848
``merge_used_characters`` methods of `.RendererPdf`, `.PdfFile`, and
4949
`.RendererPS` are deprecated.
50+
51+
Passing raw data to ``register_cmap()``
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
Passing raw data via parameters *data* and *lut* to ``register_cmap()`` is
54+
deprecated. Instead, create the colormap explicitly using
55+
``register_cmap(cmap=LinearSementedColormap(name, data, lut))``.

‎lib/matplotlib/cm.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
9090
instance. The *name* is optional; if absent, the name will
9191
be the :attr:`~matplotlib.colors.Colormap.name` attribute of the *cmap*.
9292
93-
In thesecond case, the three arguments are passed to
93+
Thesecond case is deprecated. Here, the three arguments are passed to
9494
the :class:`~matplotlib.colors.LinearSegmentedColormap` initializer,
95-
and the resulting colormap is registered.
95+
and the resulting colormap is registered. Instead of this implicit
96+
colormap creation, use the first case by calling
97+
``register_cmap(cmap=LinearSementedColormap(name, data, lut))``.
9698
"""
9799
cbook._check_isinstance((str,None),name=name)
98100
ifnameisNone:
@@ -103,6 +105,13 @@ def register_cmap(name=None, cmap=None, data=None, lut=None):
103105
ifisinstance(cmap,colors.Colormap):
104106
cmap_d[name]=cmap
105107
return
108+
iflutisnotNoneordataisnotNone:
109+
cbook.warn_deprecated(
110+
"3.3",
111+
message="Passing raw data via parameters data and lut to "
112+
"register_cmap() is deprecated. Instead use: "
113+
"register_cmap("
114+
"cmap=LinearSementedColormap(name, data, lut))")
106115
# For the remainder, let exceptions propagate.
107116
iflutisNone:
108117
lut=mpl.rcParams['image.lut']

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp