Skip to content

Commit ae85a8c

Browse files
authored
Merge pull request #16761 from meeseeksmachine/auto-backport-of-pr-16745-on-v3.2.x
Backport PR #16745 on branch v3.2.x (Allow numbers to set uvc for all arrows in quiver.set_UVC, fixes #16743)
2 parents 9da2546 + 7c13fae commit ae85a8c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/matplotlib/quiver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def set_UVC(self, U, V, C=None):
600600
if C is not None:
601601
C = ma.masked_invalid(C, copy=True).ravel()
602602
for name, var in zip(('U', 'V', 'C'), (U, V, C)):
603-
if var is not None and var.size != self.N:
603+
if not (var is None or var.size == self.N or var.size == 1):
604604
raise ValueError(f'Argument {name} has a size {var.size}'
605605
f' which does not match {self.N},'
606606
' the number of arrow positions')

lib/matplotlib/tests/test_quiver.py

+12
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,15 @@ def test_quiverkey_angles():
252252
# The arrows are only created when the key is drawn
253253
fig.canvas.draw()
254254
assert len(qk.verts) == 1
255+
256+
257+
def test_quiver_setuvc_numbers():
258+
"""Check that it is possible to set all arrow UVC to the same numbers"""
259+
260+
fig, ax = plt.subplots()
261+
262+
X, Y = np.meshgrid(np.arange(2), np.arange(2))
263+
U = V = np.ones_like(X)
264+
265+
q = ax.quiver(X, Y, U, V)
266+
q.set_UVC(0, 1)

0 commit comments

Comments
 (0)