136
136
is less than this, plot a dot (hexagon) of this diameter instead.
137
137
Default is 1.
138
138
139
- *pivot*: [ 'tail' | 'middle' | 'tip' ]
139
+ *pivot*: [ 'tail' | 'mid' | ' middle' | 'tip' ]
140
140
The part of the arrow that is at the grid point; the arrow rotates
141
141
about this point, hence the name *pivot*.
142
142
@@ -405,6 +405,8 @@ class Quiver(mcollections.PolyCollection):
405
405
in the draw() method.
406
406
"""
407
407
408
+ _PIVOT_VALS = ('tail' , 'mid' , 'middle' , 'tip' )
409
+
408
410
@docstring .Substitution (_quiver_doc )
409
411
def __init__ (self , ax , * args , ** kw ):
410
412
"""
@@ -430,7 +432,18 @@ def __init__(self, ax, *args, **kw):
430
432
self .angles = kw .pop ('angles' , 'uv' )
431
433
self .width = kw .pop ('width' , None )
432
434
self .color = kw .pop ('color' , 'k' )
433
- self .pivot = kw .pop ('pivot' , 'tail' )
435
+
436
+ pivot = kw .pop ('pivot' , 'tail' ).lower ()
437
+ # validate pivot
438
+ if pivot not in self ._PIVOT_VALS :
439
+ raise ValueError (
440
+ 'pivot must be one of {keys}, you passed {inp}' .format (
441
+ keys = self ._PIVOT_VALS , inp = pivot ))
442
+ # normalize to 'middle'
443
+ if pivot == 'mid' :
444
+ pivot = 'middle'
445
+ self .pivot = pivot
446
+
434
447
self .transform = kw .pop ('transform' , ax .transData )
435
448
kw .setdefault ('facecolors' , self .color )
436
449
kw .setdefault ('linewidths' , (0 ,))
@@ -681,9 +694,9 @@ def _h_arrows(self, length):
681
694
# Now select X0, Y0 if short, otherwise X, Y
682
695
cbook ._putmask (X , short , X0 )
683
696
cbook ._putmask (Y , short , Y0 )
684
- if self .pivot [: 3 ] == 'mid ' :
697
+ if self .pivot == 'middle ' :
685
698
X -= 0.5 * X [:, 3 , np .newaxis ]
686
- elif self .pivot [: 3 ] == 'tip' :
699
+ elif self .pivot == 'tip' :
687
700
X = X - X [:, 3 , np .newaxis ] # numpy bug? using -= does not
688
701
# work here unless we multiply
689
702
# by a float first, as with 'mid'.
0 commit comments