@@ -449,7 +449,7 @@ class Quiver(mcollections.PolyCollection):
449
449
The API methods are set_UVC(), set_U(), set_V() and set_C(), which
450
450
can be used to change the size, orientation, and color of the
451
451
arrows; their locations are fixed when the class is
452
- instantiated. Possibly this method will be useful
452
+ instantiated. Possibly these methods will be useful
453
453
in animations.
454
454
455
455
Much of the work in this class is done in the draw()
@@ -477,8 +477,6 @@ def __init__(self, ax, *args,
477
477
X , Y , U , V , C = _parse_args (* args , caller_name = 'quiver' )
478
478
self .X = X
479
479
self .Y = Y
480
- self .XY = np .column_stack ((X , Y ))
481
- self .N = len (X )
482
480
self .scale = scale
483
481
self .headwidth = headwidth
484
482
self .headlength = float (headlength )
@@ -525,6 +523,14 @@ def _init(self):
525
523
526
524
self ._dpi_at_last_init = self .axes .figure .dpi
527
525
526
+ @property
527
+ def N (self ):
528
+ return len (self .X )
529
+
530
+ @property
531
+ def XY (self ):
532
+ return np .column_stack ((self .X , self .Y ))
533
+
528
534
def get_datalim (self , transData ):
529
535
trans = self .get_transform ()
530
536
offset_trf = self .get_offset_transform ()
@@ -563,10 +569,13 @@ def set_UVC(self, U, V, C=None):
563
569
----------
564
570
U : ArrayLike | None
565
571
The x direction components of the arrows. If None it is unchanged.
572
+ The size must the same as the existing U, V or be one.
566
573
V : ArrayLike | None
567
574
The y direction components of the arrows. If None it is unchanged.
575
+ The size must the same as the existing U, V or be one.
568
576
C : ArrayLike | None, optional
569
577
The arrow colors. The default is None.
578
+ The size must the same as the existing U, V or be one.
570
579
"""
571
580
if U is None :
572
581
U = self .U
@@ -598,6 +607,19 @@ def set_UVC(self, U, V, C=None):
598
607
self .set_array (C )
599
608
self .stale = True
600
609
610
+ def set_offsets (self , xy ):
611
+ """
612
+ Set the offsets for the arrows. This saves the offsets passed
613
+ in and masks them as appropriate for the existing X/Y data.
614
+
615
+ Parameters
616
+ ----------
617
+ xy : sequence of pairs of floats
618
+ """
619
+ self .X , self .Y = xy [:, 0 ], xy [:, 1 ]
620
+ super ().set_offsets (xy )
621
+ self .stale = True
622
+
601
623
def _dots_per_unit (self , units ):
602
624
"""Return a scale factor for converting from units to pixels."""
603
625
bb = self .axes .bbox
0 commit comments