8000 Remove Axes-related things deprecated in 3.3. · matplotlib/matplotlib@c3b5114 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3b5114

Browse files
committed
Remove Axes-related things deprecated in 3.3.
1 parent be02b50 commit c3b5114

File tree

6 files changed

+52
-69
lines changed

6 files changed

+52
-69
lines changed

doc/api/next_api_changes/removals/20447-ES.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ Use its more explicit synonym, ``which="major"``, instead.
2828
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929
All parameters of `.pyplot.tight_layout` are now keyword-only, to be consistent
3030
with `.Figure.tight_layout`.
31+
32+
Parameters *norm* and *vmin*/*vmax* may not be used simultaneously
33+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
Passing parameters *norm* and *vmin*/*vmax* simultaneously to functions using
35+
colormapping such as ``scatter()`` and ``imshow()`` is no longer supported.
36+
Instead of ``norm=LogNorm(), vmin=min_val, vmax=max_val`` pass
37+
``norm=LogNorm(min_val, max_val)``. *vmin* and *vmax* should only be used
38+
without setting *norm*.
39+
40+
`.Axes.annotate` and `.pyplot.annotate` parameter name changed
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
The parameter *s* to `.Axes.annotate` and `.pyplot.annotate` has previously
43+
been renamed to *text*, matching `.Annotation`. The old parameter name is no
44+
longer supported.
45+
46+
*orientation* of ``eventplot()`` and `.EventCollection`
47+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48+
Setting the *orientation* of an ``eventplot()`` or `.EventCollection` to "none"
49+
or None is no longer supported; set it to "horizontal" instead. Moreover, the two
50+
orientations ("horizontal" and "vertical") are now case-sensitive.

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
@@ -93,7 +93,7 @@ Parameters *norm* and *vmin*/*vmax* should not be used simultaneously
9393
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9494
Passing parameters *norm* and *vmin*/*vmax* simultaneously to functions using
9595
colormapping such as ``scatter()`` and ``imshow()`` is deprecated.
96-
Inestead of ``norm=LogNorm(), vmin=min_val, vmax=max_val`` pass
96+
Instead of ``norm=LogNorm(), vmin=min_val, vmax=max_val`` pass
9797
``norm=LogNorm(min_val, max_val)``. *vmin* and *vmax* should only be used
9898
without setting *norm*.
9999

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ def text(self, x, y, s, fontdict=None, **kwargs):
661661
self._add_text(t)
662662
return t
663663

664-
@_api.rename_parameter("3.3", "s", "text")
665664
@docstring.dedent_interpd
666665
def annotate(self, text, xy, *args, **kwargs):
667666
a = mtext.Annotation(text, xy, *args, **kwargs)
@@ -1367,10 +1366,9 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
13671366
minline = (lineoffsets - linelengths).min()
13681367
maxline = (lineoffsets + linelengths).max()
13691368

1370-
if (orientation is not None and
1371-
orientation.lower() == "vertical"):
1369+
if orientation == "vertical":
13721370
corners = (minline, minpos), (maxline, maxpos)
1373-
else: # "horizontal", None or "none" (see EventCollection)
1371+
else: # "horizontal"
13741372
corners = (minpos, minline), (maxpos, maxline)
13751373
self.update_datalim(corners)
13761374
self._request_autoscale_view()
@@ -4399,7 +4397,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43994397
*vmin* and *vmax* are used in conjunction with the default norm to
44004398
map the color array *c* to the colormap *cmap*. If None, the
44014399
respective min and max of the color array is used.
4402-
It is deprecated to use *vmin*/*vmax* when *norm* is given.
4400+
It is an error to use *vmin*/*vmax* when *norm* is given.
44034401
44044402
alpha : float, default: None
44054403
The alpha blending value, between 0 (transparent) and 1 (opaque).
@@ -4690,7 +4688,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
46904688
automatically chosen by the `.Normalize` instance (defaults to
46914689
the respective min/max values of the bins in case of the default
46924690
linear scaling).
4693-
It is deprecated to use *vmin*/*vmax* when *norm* is given.
4691+
It is an error to use *vmin*/*vmax* when *norm* is given.
46944692
46954693
alpha : float between 0 and 1, optional
46964694
The alpha blending value, between 0 (transparent) and 1 (opaque).
@@ -5487,7 +5485,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
54875485
When using scalar data and no explicit *norm*, *vmin* and *vmax*
54885486
define the data range that the colormap covers. By default,
54895487
the colormap covers the complete value range of the supplied
5490-
data. It is deprecated to use *vmin*/*vmax* when *norm* is given.
5488+
data. It is an error to use *vmin*/*vmax* when *norm* is given.
54915489
When using RGB(A) data, parameters *vmin*/*vmax* are ignored.
54925490
54935491
origin : {'upper', 'lower'}, default: :rc:`image.origin`
@@ -5809,7 +5807,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
58095807
automatically chosen by the `.Normalize` instance (defaults to
58105808
the respective min/max values of *C* in case of the default linear
58115809
scaling).
5812-
It is deprecated to use *vmin*/*vmax* when *norm* is given.
5810+
It is an error to use *vmin*/*vmax* when *norm* is given.
58135811
58145812
edgecolors : {'none', None, 'face', color, color sequence}, optional
58155813
The color of the edges. Defaults to 'none'. Possible values:
@@ -6039,7 +6037,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60396037
automatically chosen by the `.Normalize` instance (defaults to
60406038
the respective min/max values of *C* in case of the default linear
60416039
scaling).
6042-
It is deprecated to use *vmin*/*vmax* when *norm* is given.
6040+
It is an error to use *vmin*/*vmax* when *norm* is given.
60436041
60446042
edgecolors : {'none', None, 'face', color, color sequence}, optional
60456043
The color of the edges. Defaults to 'none'. Possible values:
@@ -6290,7 +6288,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62906288
automatically chosen by the `.Normalize` instance (defaults to
62916289
the respective min/max values of *C* in case of the default linear
62926290
scaling).
6293-
It is deprecated to use *vmin*/*vmax* when *norm* is given.
6291+
It is an error to use *vmin*/*vmax* when *norm* is given.
62946292
62956293
alpha : float, default: None
62966294
The alpha blending value, between 0 (transparent) and 1 (opaque).

lib/matplotlib/cm.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,10 @@ def _scale_norm(self, norm, vmin, vmax):
278278
if vmin is not None or vmax is not None:
279279
self.set_clim(vmin, vmax)
280280
if norm is not None:
281-
_api.warn_deprecated(
282-
"3.3",
283-
message="Passing parameters norm and vmin/vmax "
284-
"simultaneously is deprecated since %(since)s and "
285-
"will become an error %(removal)s. Please pass "
286-
"vmin/vmax directly to the norm when creating it.")
281+
raise ValueError(
282+
"Passing parameters norm and vmin/vmax simultaneously is "
283+
"not supported. Please pass vmin/vmax directly to the "
284+
"norm when creating it.")
287285

288286
# always resolve the autoscaling so we have concrete limits
289287
# rather than deferring to draw time.

lib/matplotlib/collections.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,32 +1634,17 @@ def switch_orientation(self):
16341634
self._is_horizontal = not self.is_horizontal()
16351635
self.stale = True
16361636

1637-
def set_orientation(self, orientation=None):
1637+
def set_orientation(self, orientation):
16381638
"""
16391639
Set the orientation of the event line.
16401640
16411641
Parameters
16421642
----------
16431643
orientation : {'horizontal', 'vertical'}
16441644
"""
1645-
try:
1646-
is_horizontal = _api.check_getitem(
1647-
{"horizontal": True, "vertical": False},
1648-
orientation=orientation)
1649-
except ValueError:
1650-
if (orientation is None or orientation.lower() == "none"
1651-
or orientation.lower() == "horizontal"):
1652-
is_horizontal = True
1653-
elif orientation.lower() == "vertical":
1654-
is_horizontal = False
1655-
else:
1656-
raise
1657-
normalized = "horizontal" if is_horizontal else "vertical"
1658-
_api.warn_deprecated(
1659-
"3.3", message="Support for setting the orientation of "
1660-
f"EventCollection to {orientation!r} is deprecated since "
1661-
f"%(since)s and will be removed %(removal)s; please set it to "
1662-
f"{normalized!r} instead.")
1645+
is_horizontal = _api.check_getitem(
1646+
{"horizontal": True, "vertical": False},
1647+
orientation=orientation)
16631648
if is_horizontal == self.is_horizontal():
16641649
return
16651650
self.switch_orientation()

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from collections import namedtuple
2-
< F987 span class=pl-k>from contextlib import nullcontext
32
import datetime
43
from decimal import Decimal
54
import io
@@ -536,14 +535,6 @@ def test_basic_annotate():
536535
xytext=(3, 3), textcoords='offset points')
537536

538537

539-
def test_annotate_parameter_warn():
540-
fig, ax = plt.subplots()
541-
with pytest.warns(MatplotlibDeprecationWarning,
542-
match=r"The \'s\' parameter of annotate\(\) "
543-
"has been renamed \'text\'"):
544-
ax.annotate(s='now named text', xy=(0, 1))
545-
546-
547538
@image_comparison(['arrow_simple.png'], remove_text=True)
548539
def test_arrow_simple():
549540
# Simple image test for ax.arrow
@@ -896,16 +887,13 @@ def test_imshow_clip():
896887
ax.imshow(r, clip_path=clip_path)
897888

898889

899-
@check_figures_equal(extensions=["png"])
900-
def test_imshow_norm_vminvmax(fig_test, fig_ref):
901-
"""Parameters vmin, vmax should be ignored if norm is given."""
890+
def test_imshow_norm_vminvmax():
891+
"""Parameters vmin, vmax should error if norm is given."""
902892
a = [[1, 2], [3, 4]]
903-
ax = fig_ref.subplots()
904-
ax.imshow(a, vmin=0, vmax=5)
905-
ax = fig_test.subplots()
906-
with pytest.warns(MatplotlibDeprecationWarning,
907-
match="Passing parameters norm and vmin/vmax "
908-
"simultaneously is deprecated."):
893+
ax = plt.axes()
894+
with pytest.raises(ValueError,
895+
match="Passing parameters norm and vmin/vmax "
896+
"simultaneously is not supported."):
909897
ax.imshow(a, norm=mcolors.Normalize(-10, 10), vmin=0, vmax=5)
910898

911899

@@ -2259,16 +2247,13 @@ def test_scatter_no_invalid_color(self, fig_test, fig_ref):
22592247
ax = fig_ref.subplots()
22602248
ax.scatter([0, 2], [0, 2], c=[1, 2], s=[1, 3], cmap=cmap)
22612249

2262-
@check_figures_equal(extensions=["png"])
2263-
def test_scatter_norm_vminvmax(self, fig_test, fig_ref):
2264-
"""Parameters vmin, vmax should be ignored if norm is given."""
2250+
def test_scatter_norm_vminvmax(self):
2251+
"""Parameters vmin, vmax should error if norm is given."""
22652252
x = [1, 2, 3]
2266-
ax = fig_ref.subplots()
2267-
ax.scatter(x, x, c=x, vmin=0, vmax=5)
2268-
ax = fig_test.subplots()
2269-
with pytest.warns(MatplotlibDeprecationWarning,
2270-
match="Passing parameters norm and vmin/vmax "
2271-
"simultaneously is deprecated."):
2253+
ax = plt.axes()
2254+
with pytest.raises(ValueError,
2255+
match="Passing parameters norm and vmin/vmax "
2256+
"simultaneously is not supported."):
22722257
ax.scatter(x, x, c=x, norm=mcolors.Normalize(-10, 10),
22732258
vmin=0, vmax=5)
22742259

@@ -4112,15 +4097,12 @@ def test_empty_eventplot():
41124097

41134098

41144099
@pytest.mark.parametrize('data', [[[]], [[], [0, 1]], [[0, 1], []]])
4115-
@pytest.mark.parametrize(
4116-
'orientation', ['_empty', 'vertical', 'horizontal', None, 'none'])
4100+
@pytest.mark.parametrize('orientation', [None, 'vertical', 'horizontal'])
41174101
def test_eventplot_orientation(data, orientation):
41184102
"""Introduced when fixing issue #6412."""
4119-
opts = {} if orientation == "_empty" else {'orientation': orientation}
4103+
opts = {} if orientation is None else {'orientation': orientation}
41204104
fig, ax = plt.subplots(1, 1)
4121-
with (pytest.warns(MatplotlibDeprecationWarning)
4122-
if orientation in [None, 'none'] else nullcontext()):
4123-
ax.eventplot(data, **opts)
4105+
ax.eventplot(data, **opts)
41244106
plt.draw()
41254107

41264108

0 commit comments

Comments
 (0)
0