Skip to content

Commit 35a3379

Browse files
committed
DOC: Improve quiver docs
Follow up to matplotlib#30784.
1 parent 76327b5 commit 35a3379

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

lib/matplotlib/quiver.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@
247247
248248
Notes
249249
-----
250+
**Data shape**
251+
252+
2D inputs for *X*, *Y*, *U*, *V*, *C* are only for convenience. The internal
253+
storage and thus the respective attributes are always a ravelled 1D array.
250254
251255
**Arrow shape**
252256
@@ -446,6 +450,13 @@ def _parse_args(*args, caller_name='function'):
446450
447451
caller_name : str
448452
Name of the calling method (used in error messages).
453+
454+
Returns
455+
-------
456+
X, Y : ndarray
457+
Position coordinates as ravelled 1d arrays.
458+
U, V, C : ndarray or None
459+
Arrow direction components and numeric data as passed in.
449460
"""
450461
X = Y = C = None
451462

@@ -584,6 +595,26 @@ def draw(self, renderer):
584595
self.stale = False
585596

586597
def set_UVC(self, U, V, C=None):
598+
"""
599+
Update the quiver arrow directions and color.
600+
601+
Parameters
602+
----------
603+
U, V : 1D or 2D array-like
604+
The new x and y direction components of the arrow vectors. See also
605+
*U*, *V* in the `.Quiver` documentation.
606+
C : 1D or 2D array-like, optional
607+
Numeric data to be colormapped for each arrow. See also the
608+
`.Quiver` documentation. If not given, previous *C* values are
609+
preserved.
610+
611+
Notes
612+
-----
613+
*U*, *V*, and *C* must have the same number of elements as there are
614+
arrows in the Quiver. If you want to change the number / positions of
615+
arrows as well, update `.Quiver.set_offsets` before calling
616+
`.Quiver.set_UVC`.
617+
"""
587618
# We need to ensure we have a copy, not a reference
588619
# to an array that might change before draw().
589620
U = ma.masked_invalid(U, copy=True).ravel()
@@ -1162,6 +1193,26 @@ def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length,
11621193
return barb_list
11631194

11641195
def set_UVC(self, U, V, C=None):
1196+
"""
1197+
Update the barb directions and colors.
1198+
1199+
Parameters
1200+
----------
1201+
U, V : 1D or 2D array-like
1202+
The new x and y direction components of the barbs. See also
1203+
*U*, *V* in the `.Barbs` documentation.
1204+
C : 1D or 2D array-like, optional
1205+
Numeric data to be colormapped for each barb. See also the
1206+
`.Barbs` documentation. If not given, previous *C* values are
1207+
preserved.
1208+
1209+
Notes
1210+
-----
1211+
*U*, *V*, and *C* must have the same number of elements as there are
1212+
arrows in the Quiver. If you want to change the number / positions of
1213+
arrows as well, update `.Barbs.set_offsets` before calling
1214+
`.Barbs.set_UVC`.
1215+
"""
11651216
# We need to ensure we have a copy, not a reference to an array that
11661217
# might change before draw().
11671218
self.u = ma.masked_invalid(U, copy=True).ravel()

0 commit comments

Comments
 (0)