@@ -454,11 +454,10 @@ class Quiver(mcollections.PolyCollection):
454
454
"""
455
455
Specialized PolyCollection for arrows.
456
456
457
- The API methods are set_UVC(), set_U(), set_V() and set_C(), which
458
- can be used to change the size, orientation, and color of the
459
- arrows; their locations are fixed when the class is
460
- instantiated. Possibly these methods will be useful
461
- in animations.
457
+ The API methods are set_XYUVC(), set_X(), set_Y(), set_U() and set_V(),
458
+ which can be used to change the size, orientation, and color of the
459
+ arrows; their locations are fixed when the class is instantiated.
460
+ Possibly these methods will be useful in animations.
462
461
463
462
Much of the work in this class is done in the draw()
464
463
method so that as much information as possible is available
@@ -512,7 +511,7 @@ def __init__(self, ax, *args,
512
511
X , Y , U , V , C , self ._nr , self ._nc = _parse_args (
513
512
* args , caller_name = 'quiver()'
514
513
)
515
- self .set_XYUVC (X = X , Y = Y , U = U , V = V , C = C )
514
+ self .set_XYUVC (X = X , Y = Y , U = U , V = V , C = C , check_shape = True )
516
515
self ._dpi_at_last_init = None
517
516
518
517
def _init (self ):
@@ -547,59 +546,49 @@ def X(self):
547
546
return self .get_X ()
548
547
549
548
@X .setter
550
- def X (self ):
549
+ def X (self , value ):
551
550
_api .warn_deprecated ("3.9" , alternative = "set_X" )
552
- return self .set_X ()
551
+ return self .set_X (value )
553
552
554
553
@property
555
554
def Y (self ):
556
555
_api .warn_deprecated ("3.9" , alternative = "get_Y" )
557
556
return self .get_Y ()
558
557
559
558
@Y .setter
560
- def Y (self ):
559
+ def Y (self , value ):
561
560
_api .warn_deprecated ("3.9" , alternative = "set_Y" )
562
- return self .set_Y ()
561
+ return self .set_Y (value )
563
562
564
563
@property
565
564
def U (self ):
566
565
_api .warn_deprecated ("3.9" , alternative = "get_U")
567
566
return self .get_U ()
568
567
569
568
@U .setter
570
- def U (self ):
569
+ def U (self , value ):
571
570
_api .warn_deprecated ("3.9" , alternative = "set_U" )
572
- return self .set_U ()
571
+ return self .set_U (value )
573
572
574
573
@property
575
574
def V (self ):
576
575
_api .warn_deprecated ("3.9" , alternative = "get_V" )
577
576
return self .get_V ()
578
577
579
578
@V .setter
580
- def V (self ):
579
+ def V (self , value ):
581
580
_api .warn_deprecated ("3.9" , alternative = "set_V" )
582
- return self .set_V ()
583
-
584
- @property
585
- def C (self ):
586
- _api .warn_deprecated ("3.9" , alternative = "get_C" )
587
- return self .get_C ()
588
-
589
- @C .setter
590
- def C (self ):
591
- _api .warn_deprecated ("3.9" , alternative = "set_C" )
592
- return self .set_C ()
581
+ return self .set_V (value )
593
582
594
583
@property
595
584
def XY (self ):
596
- _api .warn_deprecated ("3.9" , alternative = "get_XY " )
585
+ _api .warn_deprecated ("3.9" , alternative = "get_offsets " )
597
586
return self .get_offsets ()
598
587
599
588
@XY .setter
600
- def XY (self , XY ):
601
- _api .warn_deprecated ("3.9" , alternative = "set_XY " )
602
- self .set_offsets (offsets = XY )
589
+ def XY (self , value ):
590
+ _api .warn_deprecated ("3.9" , alternative = "set_offsets " )
591
+ self .set_offsets (offsets = value )
603
592
604
593
def set_offsets (self , offsets ):
605
594
self .set_XYUVC (X = offsets [:, 0 ], Y = offsets [:, 1 ])
@@ -621,23 +610,6 @@ def draw(self, renderer):
621
610
super ().draw (renderer )
622
611
self .stale = False
623
612
624
- def get_XY (self ):
625
- """Returns the positions. Alias for ``get_offsets``."""
626
- return self .get_offsets ()
627
-
628
- def set_XY (self , XY ):
629
- """
630
- Set positions. Alias for ``set_offsets``. If the size
631
- changes and it is not compatible with ``U``, ``V`` or
632
- ``C``, use ``set_XYUVC`` instead.
633
-
634
- Parameters
635
- ----------
636
- X : array-like
637
- The size must be compatible with ``U``, ``V`` and ``C``.
638
- """
639
- self .set_offsets (offsets = XY )
640
-
641
613
def set_X (self , X ):
642
614
"""
643
615
Set positions in the horizontal direction.
@@ -698,22 +670,7 @@ def get_V(self):
698
670
"""Returns the vertical direction components."""
699
671
return self ._V
700
672
701
- def set_C (self , C ):
702
- """
703
- Set the arrow colors.
704
-
705
- Parameters
706
- ----------
707
- C : array-like
708
- The size must the same as the existing X, Y, U, V or be one.
709
- """
710
- self .set_XYUVC (C = C )
711
-
712
- def get_C (self ):
713
- """Returns the arrow colors."""
714
- return self ._C
715
-
716
- def set_XYUVC (self , X = None , Y = None , U = None , V = None , C = None ):
673
+ def set_XYUVC (self , X = None , Y = None , U = None , V = None , C = None , check_shape = False ):
717
674
"""
718
675
Set the positions (X, Y) and components (U, V) of the arrow vectors
719
676
and arrow colors (C) values of the arrows.
@@ -733,6 +690,9 @@ def set_XYUVC(self, X=None, Y=None, U=None, V=None, C=None):
733
690
C : array-like or None, optional
734
691
The arrow colors. The default is None.
735
692
The size must the same as the existing U, V or be one.
693
+ check_shape : bool
694
+ Whether to check if the shape of the parameters are
695
+ consistent. Default is False.
736
696
"""
737
697
738
698
X = self .get_X () if X is None else X
@@ -752,13 +712,14 @@ def set_XYUVC(self, X=None, Y=None, U=None, V=None, C=None):
752
712
C = ma .masked_invalid (
753
713
self ._C if C is None else C , copy = True
754
714
).ravel ()
755
- for name , var in zip (('U' , 'V' , 'C' ), (U , V , C )):
756
- if not (var is None or var .size == N or var .size == 1 ):
757
- raise ValueError (
758
- f'Argument { name } has a size { var .size } '
759
- f' which does not match { N } ,'
760
- ' the number of arrow positions'
761
- )
715
+ if check_shape :
716
+ for name , var in zip (('U' , 'V' , 'C' ), (U , V , C )):
717
+ if not (var is None or var .size == N or var .size == 1 ):
718
+ raise ValueError (
719
+ f'Argument { name } has a size { var .size } '
720
+ f' which does not match { N } ,'
721
+ ' the number of arrow positions'
722
+ )
762
723
763
724
# now shapes are validated and we can start assigning things
764
725
mask = ma .mask_or (U .mask , V .mask , copy = False , shrink = True )
0 commit comments