Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8a4f7f

Browse files
committed
Removed tests, updated documentation with code style for removed functions, moved code to pyplot from cm
1 parent c8d70ac commit a8a4f7f

13 files changed

Lines changed: 63 additions & 133 deletions

File tree

ci/mypy-stubtest-allowlist.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ matplotlib.figure.Figure.set_constrained_layout
4949
matplotlib.figure.Figure.set_constrained_layout_pads
5050
matplotlib.figure.Figure.set_tight_layout
5151

52-
# 3.7 deprecations
53-
5452
# 3.8 deprecations
5553
matplotlib.cbook.get_sample_data
5654
matplotlib.contour.ContourSet.allkinds
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
``matplotlib.cm.register_cmap``
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
In Matplotlib 3.5 we added a `.ColormapRegistry` class and exposed an instance
2+
at the top level as ``matplotlib.colormaps``. The existing top level functions
3+
in `matplotlib.cm` (``get_cmap``, ``register_cmap``, ``unregister_cmap``) were
4+
changed to be aliases around the same instance. In Matplotlib 3.6 we have
5+
marked those top level functions as pending deprecation.
36

4-
... was removed as it was deprecated during 3.7. Use `matplotlib.colormaps.register` instead.
7+
In Matplotlib 3.7, the following functions have been marked for deprecation:
58

6-
``matplotlib.cm.unregister_cmap``
7-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
- ``matplotlib.cm.get_cmap``; use ``matplotlib.colormaps[name]`` instead if you
10+
have a `str`.
811

9-
... was removed as it was deprecated during 3.7. Use `matplotlib.colormaps.unregister` instead.
12+
**Added 3.6.1** Use `matplotlib.cm.ColormapRegistry.get_cmap` if you
13+
have a string, `None` or a `matplotlib.colors.Colormap` object that you want
14+
to convert to a `matplotlib.colors.Colormap` instance.
15+
- ``matplotlib.cm.register_cmap``; use `matplotlib.colormaps.register
16+
<.ColormapRegistry.register>` instead
17+
- ``matplotlib.cm.unregister_cmap``; use `matplotlib.colormaps.unregister
18+
<.ColormapRegistry.unregister>` instead
19+
- ``matplotlib.pyplot.register_cmap``; use `matplotlib.colormaps.register
20+
<.ColormapRegistry.register>` instead
1021

11-
``matplotlib.pyplot.register_cmap``
12-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13-
14-
... was removed as it was deprecated during 3.7. Use `matplotlib.colormaps.register` instead.
15-
16-
``matplotlib.cm.get_cmap``
17-
~~~~~~~~~~~~~~~~~~~~~~~~~~
18-
19-
... was removed as it was deprecated during 3.7. Use `matplotlib.cm.ColormapRegistry.get_cmap` if you have a string, `None`
20-
or a `matplotlib.colors.Colormap` object that you want to convert to a `matplotlib.colors.Colormap` instance.
22+
The `matplotlib.pyplot.get_cmap` function will stay available for backward
23+
compatibility.

doc/api/prev_api_changes/api_changes_0.99.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Changes in 0.99
77
NumPy arrays.
88

99
* User-generated colormaps can now be added to the set recognized
10-
by :func:`matplotlib.cm.get_cmap`. Colormaps can be made the
10+
by ``matplotlib.cm.get_cmap``. Colormaps can be made the
1111
default and applied to the current image using
1212
:func:`matplotlib.pyplot.set_cmap`.
1313

doc/api/prev_api_changes/api_changes_3.2.0/behavior.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Exception changes
294294
~~~~~~~~~~~~~~~~~
295295
Various APIs that raised a `ValueError` for incorrectly typed inputs now raise
296296
`TypeError` instead: `.backend_bases.GraphicsContextBase.set_clip_path`,
297-
``blocking_input.BlockingInput.__call__``, `.cm.register_cmap`, `.dviread.DviFont`,
297+
``blocking_input.BlockingInput.__call__``, ``matplotlib.cm.register_cmap``, `.dviread.DviFont`,
298298
`.rcsetup.validate_hatch`, ``.rcsetup.validate_animation_writer_path``, `.spines.Spine`,
299299
many classes in the :mod:`matplotlib.transforms` module and :mod:`matplotlib.tri`
300300
package, and Axes methods that take a ``norm`` parameter.

doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Please pass capstyles ("miter", "round", "bevel") and joinstyles ("butt",
5555

5656
Passing raw data to ``register_cmap()``
5757
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58-
Passing raw data via parameters *data* and *lut* to `.register_cmap()` is
58+
Passing raw data via parameters *data* and *lut* to ``matplotlib.cm.register_cmap()`` is
5959
deprecated. Instead, explicitly create a `.LinearSegmentedColormap` and pass
6060
it via the *cmap* parameter:
6161
``register_cmap(cmap=LinearSegmentedColormap(name, data, lut))``.

doc/api/prev_api_changes/api_changes_3.4.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ time, not at draw time.
203203
Raise or warn on registering a colormap twice
204204
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205205

206-
When using `matplotlib.cm.register_cmap` to register a user provided or
206+
When using ``matplotlib.cm.register_cmap`` to register a user provided or
207207
third-party colormap it will now raise a `ValueError` if trying to over-write
208208
one of the built in colormaps and warn if trying to over write a user
209209
registered colormap. This may raise for user-registered colormaps in the

doc/api/prev_api_changes/api_changes_3.6.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Behaviour changes
44
``plt.get_cmap`` and ``matplotlib.cm.get_cmap`` return a copy
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66

7-
Formerly, `~.pyplot.get_cmap` and `.cm.get_cmap` returned a global version of a
7+
Formerly, `~.pyplot.get_cmap` and ``matplotlib.cm.get_cmap`` returned a global version of a
88
`.Colormap`. This was prone to errors as modification of the colormap would
99
propagate from one location to another without warning. Now, a new copy of the
1010
colormap is returned.

doc/api/prev_api_changes/api_changes_3.7.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ also be based on ``mpl_toolkits.axisartist``. This behavior is consistent with
2020
``plt.get_cmap`` and ``matplotlib.cm.get_cmap`` return a copy
2121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2222

23-
Formerly, `~.pyplot.get_cmap` and `.cm.get_cmap` returned a global version of a
23+
Formerly, `~.pyplot.get_cmap` and ``matplotlib.cm.get_cmap`` returned a global version of a
2424
`.Colormap`. This was prone to errors as modification of the colormap would
2525
propagate from one location to another without warning. Now, a new copy of the
2626
colormap is returned.

doc/users/prev_whats_new/whats_new_3.4.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ for out-of-range and masked values.
547547
New ``cm.unregister_cmap`` function
548548
-----------------------------------
549549

550-
`.cm.unregister_cmap` allows users to remove a colormap that they have
550+
``matplotlib.cm.unregister_cmap`` allows users to remove a colormap that they have
551551
previously registered.
552552

553553
New ``CenteredNorm`` for symmetrical data around a center

doc/users/prev_whats_new/whats_new_3.5.0.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ To register new colormaps use::
148148

149149
plt.colormaps.register(my_colormap)
150150

151-
We recommend to use the new API instead of the `~.cm.get_cmap` and
152-
`~.cm.register_cmap` functions for new code. `matplotlib.cm.get_cmap` and
153-
`matplotlib.cm.register_cmap` will eventually be deprecated and removed.
151+
We recommend to use the new API instead of the ``matplotlib.cm.get_cmap`` and
152+
``matplotlib.cm.register_cmap`` functions for new code. ``matplotlib.cm.get_cmap`` and
153+
``matplotlib.cm.register_cmap`` will eventually be deprecated and removed.
154154
Within `.pyplot`, ``plt.get_cmap()`` and ``plt.register_cmap()`` will continue
155155
to be supported for backward compatibility.
156156

0 commit comments

Comments
 (0)