diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index 1d24072fc3ef..29dad2ad91fb 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -600,7 +600,7 @@ def set_UVC(self, U, V, C=None): if C is not None: C = ma.masked_invalid(C, copy=True).ravel() for name, var in zip(('U', 'V', 'C'), (U, V, C)): - if var is not None and var.size != self.N: + if not (var is None or var.size == self.N or var.size == 1): raise ValueError(f'Argument {name} has a size {var.size}' f' which does not match {self.N},' ' the number of arrow positions') diff --git a/lib/matplotlib/tests/test_quiver.py b/lib/matplotlib/tests/test_quiver.py index 68031bff2754..719c8fbc15b8 100644 --- a/lib/matplotlib/tests/test_quiver.py +++ b/lib/matplotlib/tests/test_quiver.py @@ -252,3 +252,15 @@ def test_quiverkey_angles(): # The arrows are only created when the key is drawn fig.canvas.draw() assert len(qk.verts) == 1 + + +def test_quiver_setuvc_numbers(): + """Check that it is possible to set all arrow UVC to the same numbers""" + + fig, ax = plt.subplots() + + X, Y = np.meshgrid(np.arange(2), np.arange(2)) + U = V = np.ones_like(X) + + q = ax.quiver(X, Y, U, V) + q.set_UVC(0, 1)