Skip to content

Commit ffa6db0

Browse files
authored
Expire a mpl2.2-deprecated API (#16184)
Expire a mpl2.2-deprecated API
2 parents 154a936 + 2880433 commit ffa6db0

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ property. This now raises a TypeError.
6262
`.FileMovieWriter` now defaults to writing temporary frames in a temporary
6363
directory, which is always cleared at exit. In order to keep the individual
6464
frames saved on the filesystem, pass an explicit *frame_prefix*.
65+
66+
`.Axes.plot` no longer accepts *x* and *y* being both 2D and with different numbers of columns
67+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68+
Previously, calling `.Axes.plot` e.g. with *x* of shape ``(n, 3)`` and *y* of
69+
shape ``(n, 2)`` would plot the first column of *x* against the first column
70+
of *y*, the second column of *x* against the second column of *y*, **and** the
71+
first column of *x* against the third column of *y*. This now raises an error
72+
instead.

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def _plot_args(self, tup, kwargs):
356356

357357
ncx, ncy = x.shape[1], y.shape[1]
358358
if ncx > 1 and ncy > 1 and ncx != ncy:
359-
cbook.warn_deprecated(
360-
"2.2", message="cycling among columns of inputs with "
361-
"non-matching shapes is deprecated.")
359+
raise ValueError(f"x has {ncx} columns but y has {ncy} columns")
362360
return [func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
363361
for j in range(max(ncx, ncy))]
364362

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,12 +5479,13 @@ def test_square_plot():
54795479
ax.get_position(original=False).extents, (0.2125, 0.1, 0.8125, 0.9))
54805480

54815481

5482-
def test_no_None():
5483-
fig, ax = plt.subplots()
5482+
def test_bad_plot_args():
54845483
with pytest.raises(ValueError):
54855484
plt.plot(None)
54865485
with pytest.raises(ValueError):
54875486
plt.plot(None, None)
5487+
with pytest.raises(ValueError):
5488+
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
54885489

54895490

54905491
@pytest.mark.parametrize(
@@ -6227,11 +6228,6 @@ def test_empty_errorbar_legend():
62276228
ax.legend()
62286229

62296230

6230-
def test_plot_columns_cycle_deprecation():
6231-
with pytest.warns(MatplotlibDeprecationWarning):
6232-
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
6233-
6234-
62356231
@check_figures_equal(extensions=["png"])
62366232
def test_plot_decimal(fig_test, fig_ref):
62376233
x0 = np.arange(-10, 10, 0.3)

0 commit comments

Comments
 (0)