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

Remove cm.get_cmap#30005

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
story645 merged 5 commits intomatplotlib:mainfromdstansby:remove-get-cmap
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from2 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
11 changes: 11 additions & 0 deletionsdoc/api/next_api_changes/removals/30005-DS.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
``matplotlib.cm.get_cmap``
~~~~~~~~~~~~~~~~~~~~~~~~~~

Colormaps are now available through the `.Coloarmap.Registry` accessible via

Check warning on line 4 in doc/api/next_api_changes/removals/30005-DS.rst

View workflow job for this annotation

GitHub Actions/ sphinx

[sphinx] doc/api/next_api_changes/removals/30005-DS.rst#L4

py:obj reference target not found: Coloarmap.Registry [ref.obj]
Raw output
doc/api/next_api_changes/removals/30005-DS.rst:4: WARNING: py:obj reference target not found: Coloarmap.Registry [ref.obj]
``matplotlib.colormaps`` or ``plt.colormaps``.

If you have the name of a colormap as a sting, you can use direct lookup

Check warning on line 7 in doc/api/next_api_changes/removals/30005-DS.rst

View workflow job for this annotation

GitHub Actions/ sphinx

[sphinx] doc/api/next_api_changes/removals/30005-DS.rst#L7

py:obj reference target not found: matplotlib.colormaps.get_cmap [ref.obj]
Raw output
doc/api/next_api_changes/removals/30005-DS.rst:7: WARNING: py:obj reference target not found: matplotlib.colormaps.get_cmap [ref.obj]

Check warning on line 7 in doc/api/next_api_changes/removals/30005-DS.rst

View workflow job for this annotation

GitHub Actions/ sphinx

[sphinx] doc/api/next_api_changes/removals/30005-DS.rst#L7

py:obj reference target not found: plt.get_cmap [ref.obj]
Raw output
doc/api/next_api_changes/removals/30005-DS.rst:7: WARNING: py:obj reference target not found: plt.get_cmap [ref.obj]

Check warning on line 7 in doc/api/next_api_changes/removals/30005-DS.rst

View workflow job for this annotation

GitHub Actions/ sphinx

[sphinx] doc/api/next_api_changes/removals/30005-DS.rst#L7

py:obj reference target not found: matplotlib.colormaps.get_cmap [ref.obj]
Raw output
doc/api/next_api_changes/removals/30005-DS.rst:7: WARNING: py:obj reference target not found: matplotlib.colormaps.get_cmap [ref.obj]
``matplotlib.colormaps[name]``. Alternatively, `matplotlib.colormaps.get_cmap` will
maintain the existing behavior of additionally passing through `.Colormap` instances
and converting ``None`` to the default colormap. `plt.get_cmap` will stay as a
shortcut to `matplotlib.colormaps.get_cmap`.
37 changes: 0 additions & 37 deletionslib/matplotlib/cm.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,43 +243,6 @@ def get_cmap(self, cmap):
_bivar_colormaps = ColormapRegistry(bivar_cmaps)


# This is an exact copy of pyplot.get_cmap(). It was removed in 3.9, but apparently
# caused more user trouble than expected. Re-added for 3.9.1 and extended the
# deprecation period for two additional minor releases.
@_api.deprecated(
'3.7',
removal='3.11',
alternative="``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()``"
" or ``pyplot.get_cmap()``"
)
def get_cmap(name=None, lut=None):
"""
Get a colormap instance, defaulting to rc values if *name* is None.

Parameters
----------
name : `~matplotlib.colors.Colormap` or str or None, default: None
If a `.Colormap` instance, it will be returned. Otherwise, the name of
a colormap known to Matplotlib, which will be resampled by *lut*. The
default, None, means :rc:`image.cmap`.
lut : int or None, default: None
If *name* is not already a Colormap instance and *lut* is not None, the
colormap will be resampled to have *lut* entries in the lookup table.

Returns
-------
Colormap
"""
name = mpl._val_or_rc(name, 'image.cmap')
if isinstance(name, colors.Colormap):
return name
_api.check_in_list(sorted(_colormaps), name=name)
if lut is None:
return _colormaps[name]
else:
return _colormaps[name].resampled(lut)


def _ensure_cmap(cmap):
"""
Ensure that we have a `.Colormap` object.
Expand Down
2 changes: 0 additions & 2 deletionslib/matplotlib/cm.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,4 @@ _colormaps: ColormapRegistry = ...
_multivar_colormaps: ColormapRegistry = ...
_bivar_colormaps: ColormapRegistry = ...

def get_cmap(name: str | colors.Colormap | None = ..., lut: int | None = ...) -> colors.Colormap: ...

ScalarMappable = _ScalarMappable
Loading

[8]ページ先頭

©2009-2025 Movatter.jp