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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionsdoc/api/next_api_changes/deprecations.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionslib/matplotlib/cm.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 thesecond case, the three arguments are passed to
Thesecond 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

[8]ページ先頭

©2009-2025 Movatter.jp