@@ -3011,30 +3011,40 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
30113011 if tight is not None :
30123012 self ._tight = bool (tight )
30133013
3014+ x_shared = self ._shared_axes ["x" ].get_siblings (self )
3015+ y_shared = self ._shared_axes ["y" ].get_siblings (self )
3016+
30143017 x_stickies = y_stickies = np .array ([])
30153018 if self .use_sticky_edges :
30163019 if self ._xmargin and scalex and self .get_autoscalex_on ():
3017- x_stickies = np .sort (np .concatenate ([
3018- artist .sticky_edges .x
3019- for ax in self ._shared_axes ["x" ].get_siblings (self )
3020- for artist in ax .get_children ()]))
3020+ # Use ._children and ._sticky_edges directly, because the extra
3021+ # artists in .get_children() (spines, axes, titles, etc.) never
3022+ # have sticky edges, so we can skip them for performance.
3023+ x_sticky_lists = []
3024+ for ax in x_shared :
3025+ for artist in ax ._children :
3026+ if artist ._sticky_edges .x :
3027+ x_sticky_lists .append (artist ._sticky_edges .x )
3028+ if x_sticky_lists :
3029+ x_stickies = np .sort (np .concatenate (x_sticky_lists ))
30213030 if self ._ymargin and scaley and self .get_autoscaley_on ():
3022- y_stickies = np .sort (np .concatenate ([
3023- artist .sticky_edges .y
3024- for ax in self ._shared_axes ["y" ].get_siblings (self )
3025- for artist in ax .get_children ()]))
3031+ y_sticky_lists = []
3032+ for ax in y_shared :
3033+ for artist in ax ._children :
3034+ if artist ._sticky_edges .y :
3035+ y_sticky_lists .append (artist ._sticky_edges .y )
3036+ if y_sticky_lists :
3037+ y_stickies = np .sort (np .concatenate (y_sticky_lists ))
30263038 if self .get_xscale () == 'log' :
30273039 x_stickies = x_stickies [x_stickies > 0 ]
30283040 if self .get_yscale () == 'log' :
30293041 y_stickies = y_stickies [y_stickies > 0 ]
30303042
30313043 def handle_single_axis (
3032- scale , shared_axes , name , axis , margin , stickies , set_bound ):
3044+ scale , shared , name , axis , margin , stickies , set_bound ):
30333045
30343046 if not (scale and axis ._get_autoscale_on ()):
30353047 return # nothing to do...
3036-
3037- shared = shared_axes .get_siblings (self )
30383048 # Base autoscaling on finite data limits when there is at least one
30393049 # finite data limit among all the shared_axes and intervals.
30403050 values = [val for ax in shared
@@ -3091,10 +3101,10 @@ def handle_single_axis(
30913101 # End of definition of internal function 'handle_single_axis'.
30923102
30933103 handle_single_axis (
3094- scalex , self . _shared_axes [ "x" ] , 'x' , self .xaxis , self ._xmargin ,
3104+ scalex , x_shared , 'x' , self .xaxis , self ._xmargin ,
30953105 x_stickies , self .set_xbound )
30963106 handle_single_axis (
3097- scaley , self . _shared_axes [ "y" ] , 'y' , self .yaxis , self ._ymargin ,
3107+ scaley , y_shared , 'y' , self .yaxis , self ._ymargin ,
30983108 y_stickies , self .set_ybound )
30993109
31003110 def _update_title_position (self , renderer ):
0 commit comments