8000 Merge branch 'matplotlib:main' into bug-fix-issue-20243 · matplotlib/matplotlib@e8d95d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e8d95d9

Browse files
Merge branch 'matplotlib:main' into bug-fix-issue-20243
2 parents 260593d + a916809 commit e8d95d9

File tree

6 files changed

+34
-47
lines changed

6 files changed

+34
-47
lines changed

doc/_static/switcher.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"name": "3.10 (stable)",
4-
"version": "3.10.1",
4+
"version": "3.10.3",
55
"url": "https://matplotlib.org/stable/",
66
"preferred": true
77
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
``matplotlib.cm.get_cmap``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Colormaps are now available through the `.ColormapRegistry` accessible via
5+
`matplotlib.colormaps` or `matplotlib.pyplot.colormaps`.
6+
7+
If you have the name of a colormap as a string, you can use a direct lookup,
8+
``matplotlib.colormaps[name]`` or ``matplotlib.pyplot.colormaps[name]`` . Alternatively, ``matplotlib.colormaps.get_cmap`` will
9+
maintain the existing behavior of additionally passing through `.Colormap` instances
10+
and converting ``None`` to the default colormap. `matplotlib.pyplot.get_cmap` will stay as a
11+
shortcut to ``matplotlib.colormaps.get_cmap``.

doc/devel/api_changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ have to learn new API and have to modify existing code).
6767
You can start simple and look at the search results, if there are too many
6868
incorrect matches, gradually refine your search criteria.
6969

70+
It can also be helpful to add ``NOT path:**/matplotlib/** NOT path:**/site-packages/**``
71+
to exclude matches where the matplotlib codebase is checked into another repo,
72+
either as direct sources or as part of an environment.
73+
7074
*Example*: Calls of the method ``Figure.draw()`` could be matched using
7175
``/\bfig(ure)?\.draw\(/``. This expression employs a number of patterns:
7276

doc/devel/release_guide.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,24 @@ Update :file:`doc/users/release_notes.rst`:
233233
../api/prev_api_changes/api_changes_X.Y.Z.rst
234234
prev_whats_new/github_stats_X.Y.Z.rst
235235
236+
.. _update-version-switcher:
237+
236238
Update version switcher
237-
^^^^^^^^^^^^^^^^^^^^^^^
239+
-----------------------
240+
241+
The version switcher is populated from https://matplotlib.org/devdocs/_static/switcher.json.
242+
243+
Since it's always taken from devdocs, update the file :file:`doc/_static/switcher.json`
244+
on the main branch through a regular PR:
238245

239-
Update ``doc/_static/switcher.json``:
246+
- If a micro release, update the version from :samp:`{X}.{Y}.{Z-1}` to :samp:`{X}.{Y}.{Z}`
247+
- If a meso release :samp:`{X}.{Y}.0`:
240248

241-
- If a micro release, :samp:`{X}.{Y}.{Z}`, no changes are needed.
242-
- If a meso release, :samp:`{X}.{Y}.0`, change the name of :samp:`name: {X}.{Y+1} (dev)`
243-
and :samp:`name: {X}.{Y} (stable)` as well as adding a new version for the previous
244-
stable (:samp:`name: {X}.{Y-1}`).
249+
+ update the dev entry to :samp:`name: {X}.{Y+1} (dev)`
250+
+ update the stable entry to :samp:`name: {X}.{Y} (stable)`
251+
+ add a new entry for the previous stable (:samp:`name: {X}.{Y-1}`).
252+
253+
Once that PR is merged, the devdocs site will be updated automatically.
245254

246255
Verify that docs build
247256
----------------------
@@ -451,7 +460,7 @@ which will copy the built docs over. If this is a final release, link the
451460
rm stable
452461
ln -s 3.7.0 stable
453462

454-
You will also need to edit :file:`sitemap.xml` and :file:`versions.html` to include
463+
You will also need to edit :file:`sitemap.xml` to include
455464
the newly released version. Now commit and push everything to GitHub ::
456465

457466
git add *
@@ -465,6 +474,8 @@ If you have access, clear the CloudFlare caches.
465474
It typically takes about 5-10 minutes for the website to process the push and update the
466475
live web page (remember to clear your browser cache).
467476

477+
Remember to :ref:`update the version switcher <update-version-switcher>`!
478+
468479
.. _release_merge_up:
469480

470481
Merge up changes to main

lib/matplotlib/cm.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -243,43 +243,6 @@ def get_cmap(self, cmap):
243243
_bivar_colormaps = ColormapRegistry(bivar_cmaps)
244244

245245

246-
# This is an exact copy of pyplot.get_cmap(). It was removed in 3.9, but apparently
247-
# caused more user trouble than expected. Re-added for 3.9.1 and extended the
248-
# deprecation period for two additional minor releases.
249-
@_api.deprecated(
250-
'3.7',
251-
removal='3.11',
252-
alternative="``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()``"
253-
" or ``pyplot.get_cmap()``"
254-
)
255-
def get_cmap(name=None, lut=None):
256-
"""
257-
Get a colormap instance, defaulting to rc values if *name* is None.
258-
259-
Parameters
260-
----------
261-
name : `~matplotlib.colors.Colormap` or str or None, default: None
262-
If a `.Colormap` instance, it will be returned. Otherwise, the name of
263-
a colormap known to Matplotlib, which will be resampled by *lut*. The
264-
default, None, means :rc:`image.cmap`.
265-
lut : int or None, default: None
266-
If *name* is not already a Colormap instance and *lut* is not None, the
267-
colormap will be resampled to have *lut* entries in the lookup table.
268-
269-
Returns
270-
-------
271-
Colormap
272-
"""
273-
name = mpl._val_or_rc(name, 'image.cmap')
274-
if isinstance(name, colors.Colormap):
275-
return name
276-
_api.check_in_list(sorted(_colormaps), name=name)
277-
if lut is None:
278-
return _colormaps[name]
279-
else:
280-
return _colormaps[name].resampled(lut)
281-
282-
283246
def _ensure_cmap(cmap):
284247
"""
285248
Ensure that we have a `.Colormap` object.

lib/matplotlib/cm.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,4 @@ _colormaps: ColormapRegistry = ...
1919
_multivar_colormaps: ColormapRegistry = ...
2020
_bivar_colormaps: ColormapRegistry = ...
2121

22-
def get_cmap(name: str | colors.Colormap | None = ..., lut: int | None = ...) -> colors.Colormap: ...
23-
2422
ScalarMappable = _ScalarMappable

0 commit comments

Comments
 (0)
0