@@ -959,15 +959,11 @@ def disable_mouse_rotation(self):
959
959
self .mouse_init (rotate_btn = [], pan_btn = [], zoom_btn = [])
960
960
961
961
def can_zoom (self ):
962
- """
963
- Return whether this Axes supports the zoom box button functionality.
964
- """
962
+ # doc-string inherited
965
963
return True
966
964
967
965
def can_pan (self ):
968
- """
969
- Return whether this Axes supports the pan button functionality.
970
- """
966
+ # doc-string inherited
971
967
return True
972
968
973
969
def sharez (self , other ):
@@ -1002,17 +998,17 @@ def _button_press(self, event):
1002
998
if event .inaxes == self :
1003
999
self .button_pressed = event .button
1004
1000
self ._sx , self ._sy = event .xdata , event .ydata
1005
- toolbar = getattr ( self .figure .canvas , " toolbar" )
1001
+ toolbar = self .figure .canvas . toolbar
1006
1002
if toolbar and toolbar ._nav_stack () is None :
1007
- self . figure . canvas . toolbar .push_current ()
1003
+ toolbar .push_current ()
1008
1004
1009
1005
def _button_release (self , event ):
1010
1006
self .button_pressed = None
1011
- toolbar = getattr ( self .figure .canvas , " toolbar" )
1007
+ toolbar = self .figure .canvas . toolbar
1012
1008
# backend_bases.release_zoom and backend_bases.release_pan call
1013
1009
# push_current, so check the navigation mode so we don't call it twice
1014
1010
if toolbar and self .get_navigate_mode () is None :
1015
- self . figure . canvas . toolbar .push_current ()
1011
+ toolbar .push_current ()
1016
1012
1017
1013
def _get_view (self ):
1018
1014
# docstring inherited
@@ -1597,12 +1593,6 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
1597
1593
1598
1594
fcolors = kwargs .pop ('facecolors' , None )
1599
1595
1600
- if fcolors is None :
1601
- color = kwargs .pop ('color' , None )
1602
- if color is None :
1603
- color = self ._get_lines .get_next_color ()
1604
- color = np .array (mcolors .to_rgba (color ))
1605
-
1606
1596
cmap = kwargs .get ('cmap' , None )
1607
1597
shade = kwargs .pop ('shade' , cmap is None )
1608
1598
if shade is None :
@@ -1677,6 +1667,11 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
1677
1667
if norm is not None :
1678
1668
polyc .set_norm (norm )
1679
1669
else :
1670
+ color = kwargs .pop ('color' , None )
1671
+ if color is None :
1672
+ color = self ._get_lines .get_next_color ()
1673
+ color = np .array (mcolors .to_rgba (color ))
1674
+
1680
1675
polyc = art3d .Poly3DCollection (
1681
1676
polys , facecolors = color , shade = shade ,
1682
1677
lightsource = lightsource , ** kwargs )
@@ -2548,31 +2543,33 @@ def quiver(self, X, Y, Z, U, V, W, *,
2548
2543
:class:`.Line3DCollection`
2549
2544
"""
2550
2545
2551
- def calc_arrows (UVW , angle = 15 ):
2546
+ def calc_arrows (UVW ):
2552
2547
# get unit direction vector perpendicular to (u, v, w)
2553
2548
x = UVW [:, 0 ]
2554
2549
y = UVW [:, 1 ]
2555
2550
norm = np .linalg .norm (UVW [:, :2 ], axis = 1 )
2556
2551
x_p = np .divide (y , norm , where = norm != 0 , out = np .zeros_like (x ))
2557
2552
y_p = np .divide (- x , norm , where = norm != 0 , out = np .ones_like (x ))
2558
2553
# compute the two arrowhead direction unit vectors
2559
- ra = math .radians (angle )
2560
- c = math .cos (ra )
2561
- s = math .sin (ra )
2554
+ rangle = math .radians (15 )
2555
+ c = math .cos (rangle )
2556
+ s = math .sin (rangle )
2562
2557
# construct the rotation matrices of shape (3, 3, n)
2558
+ r13 = y_p * s
2559
+ r32 = x_p * s
2560
+ r12 = x_p * y_p * (1 - c )
2563
2561
Rpos = np .array (
2564
- [[c + (x_p ** 2 ) * (1 - c ), x_p * y_p * ( 1 - c ), y_p * s ],
2565
- [y_p * x_p * ( 1 - c ) , c + (y_p ** 2 ) * (1 - c ), - x_p * s ],
2566
- [- y_p * s , x_p * s , np .full_like (x_p , c )]])
2562
+ [[c + (x_p ** 2 ) * (1 - c ), r12 , r13 ],
2563
+ [r12 , c + (y_p ** 2 ) * (1 - c ), - r32 ],
2564
+ [- r13 , r32 , np .full_like (x_p , c )]])
2567
2565
# opposite rotation negates all the sin terms
2568
2566
Rneg = Rpos .copy ()
2569
2567
Rneg [[0 , 1 , 2 , 2 ], [2 , 2 , 0 , 1 ]] *= - 1
2570
2568
# Batch n (3, 3) x (3) matrix multiplications ((3, 3, n) x (n, 3)).
2571
2569
Rpos_vecs = np .einsum ("ij...,...j->...i" , Rpos , UVW )
2572
2570
Rneg_vecs = np .einsum ("ij...,...j->...i" , Rneg , UVW )
2573
2571
# Stack into (n, 2, 3) result.
2574
- head_dirs = np .stack ([Rpos_vecs , Rneg_vecs ], axis = 1 )
2575
- return head_dirs
2572
+ return np .stack ([Rpos_vecs , Rneg_vecs ], axis = 1 )
2576
2573
2577
2574
had_data = self .has_data ()
2578
2575
@@ -2934,7 +2931,7 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
2934
2931
draws error bars on a subset of the data. *errorevery* =N draws
2935
2932
error bars on the points (x[::N], y[::N], z[::N]).
2936
2933
*errorevery* =(start, N) draws error bars on the points
2937
- (x[start::N], y[start::N], z[start::N]). e.g. errorevery=(6, 3)
2934
+ (x[start::N], y[start::N], z[start::N]). e.g. * errorevery* =(6, 3)
2938
2935
adds error bars to the data at (x[6], x[9], x[12], x[15], ...).
2939
2936
Used to avoid overlapping error bars when two series share x-axis
2940
2937
values.
0 commit comments