diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 1623ecf1c2c1..ba312935ddb5 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6591,7 +6591,10 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None, elif x.ndim == 2 and y.ndim == 2: style = "quadmesh" else: - raise TypeError("arguments do not match valid signatures") + raise TypeError( + f"When 3 positional parameters are passed to pcolorfast, the first " + f"two (X and Y) must be both 1D or both 2D; the given X was " + f"{x.ndim}D and the given Y was {y.ndim}D") else: raise _api.nargs_error('pcolorfast', '1 or 3', len(args)) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 5af508479592..3666b16e6dad 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -6450,6 +6450,13 @@ def test_pcolorfast(xy, data, cls): assert type(ax.pcolorfast(*xy, data)) == cls +def test_pcolorfast_bad_dims(): + fig, ax = plt.subplots() + with pytest.raises( + TypeError, match=("the given X was 1D and the given Y was 2D")): + ax.pcolorfast(np.empty(6), np.empty((4, 7)), np.empty((8, 8))) + + def test_shared_scale(): fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)