Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a547f0d

Browse files
committed
Allow numbers to set uvc for all arrows in quiver.set_UVC, fixes #16743
1 parent 2f85640 commit a547f0d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/matplotlib/quiver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def set_UVC(self, U, V, C=None):
585585
if C is not None:
586586
C = ma.masked_invalid(C, copy=True).ravel()
587587
for name, var in zip(('U', 'V', 'C'), (U, V, C)):
588-
if var is not None and var.size != self.N:
588+
if var is not None and var.size != self.N and var.size != 1:
589589
raise ValueError(f'Argument {name} has a size {var.size}'
590590
f' which does not match {self.N},'
591591
' the number of arrow positions')

lib/matplotlib/tests/test_quiver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,15 @@ def test_quiverkey_angles():
247247
# The arrows are only created when the key is drawn
248248
fig.canvas.draw()
249249
assert len(qk.verts) == 1
250+
251+
252+
def test_quiver_setuvc_numbers():
253+
"""Check that it is possible to set all arrow UVC to the same numbers"""
254+
255+
fig, ax = plt.subplots()
256+
257+
X, Y = np.meshgrid(np.arange(2), np.arange(2))
258+
U = V = np.ones_like(X)
259+
260+
q = ax.quiver(X, Y, U, V)
261+
q.set_UVC(0, 1)

0 commit comments

Comments
 (0)