@@ -1224,6 +1224,7 @@ def cla(self):
12241224 self .set_xlim (0 , 1 )
12251225 except TypeError :
12261226 pass
1227+ self .set_autoscalex_on (True )
12271228 if self ._sharey is not None :
12281229 self .sharey (self ._sharey )
12291230 else :
@@ -1232,17 +1233,14 @@ def cla(self):
12321233 self .set_ylim (0 , 1 )
12331234 except TypeError :
12341235 pass
1236+ self .set_autoscaley_on (True )
12351237
12361238 # update the minor locator for x and y axis based on rcParams
12371239 if mpl .rcParams ['xtick.minor.visible' ]:
12381240 self .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
12391241 if mpl .rcParams ['ytick.minor.visible' ]:
12401242 self .yaxis .set_minor_locator (mticker .AutoMinorLocator ())
12411243
1242- if self ._sharex is None :
1243- self ._autoscaleXon = True
1244- if self ._sharey is None :
1245- self ._autoscaleYon = True
12461244 self ._xmargin = mpl .rcParams ['axes.xmargin' ]
12471245 self ._ymargin = mpl .rcParams ['axes.ymargin' ]
12481246 self ._tight = None
@@ -2573,17 +2571,15 @@ def in_axes(self, mouseevent):
25732571 """
25742572 return self .patch .contains (mouseevent )[0 ]
25752573
2574+ get_autoscalex_on = _axis_method_wrapper ("xaxis" , "_get_autoscale_on" )
2575+ get_autoscaley_on = _axis_method_wrapper ("yaxis" , "_get_autoscale_on" )
2576+ set_autoscalex_on = _axis_method_wrapper ("xaxis" , "_set_autoscale_on" )
2577+ set_autoscaley_on = _axis_method_wrapper ("yaxis" , "_set_autoscale_on" )
2578+
25762579 def get_autoscale_on (self ):
25772580 """Return True if each axis is autoscaled, False otherwise."""
2578- return self ._autoscaleXon and self ._autoscaleYon
2579-
2580- def get_autoscalex_on (self ):
2581- """Return whether the x-axis is autoscaled."""
2582- return self ._autoscaleXon
2583-
2584- def get_autoscaley_on (self ):
2585- """Return whether the y-axis is autoscaled."""
2586- return self ._autoscaleYon
2581+ return all (axis ._get_autoscale_on ()
2582+ for axis in self ._get_axis_map ().values ())
25872583
25882584 def set_autoscale_on (self , b ):
25892585 """
@@ -2594,30 +2590,8 @@ def set_autoscale_on(self, b):
25942590 ----------
25952591 b : bool
25962592 """
2597- self ._autoscaleXon = b
2598- self ._autoscaleYon = b
2599-
2600- def set_autoscalex_on (self , b ):
2601- """
2602- Set whether the x-axis is autoscaled on the next draw or call to
2603- `.Axes.autoscale_view`.
2604-
2605- Parameters
2606- ----------
2607- b : bool
2608- """
2609- self ._autoscaleXon = b
2610-
2611- def set_autoscaley_on (self , b ):
2612- """
2613- Set whether the y-axis is autoscaled on the next draw or call to
2614- `.Axes.autoscale_view`.
2615-
2616- Parameters
2617- ----------
2618- b : bool
2619- """
2620- self ._autoscaleYon = b
2593+ for axis in self ._get_axis_map ().values ():
2594+ axis ._set_autoscale_on (b )
26212595
26222596 @property
26232597 def use_sticky_edges (self ):
@@ -2810,14 +2784,16 @@ def autoscale(self, enable=True, axis='both', tight=None):
28102784 scalex = True
28112785 scaley = True
28122786 else :
2813- scalex = False
2814- scaley = False
28152787 if axis in ['x' , 'both' ]:
2816- self ._autoscaleXon = bool (enable )
2817- scalex = self ._autoscaleXon
2788+ self .set_autoscalex_on (bool (enable ))
2789+ scalex = self .get_autoscalex_on ()
2790+ else :
2791+ scalex = False
28182792 if axis in ['y' , 'both' ]:
2819- self ._autoscaleYon = bool (enable )
2820- scaley = self ._autoscaleYon
2793+ self .set_autoscaley_on (bool (enable ))
2794+ scaley = self .get_autoscaley_on ()
2795+ else :
2796+ scaley = False
28212797 if tight and scalex :
28222798 self ._xmargin = 0
28232799 if tight and scaley :
@@ -2876,13 +2852,13 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
28762852 # called very early in the Axes init process (e.g., for twin Axes)
28772853 # when these attributes don't even exist yet, in which case
28782854 # `get_children` would raise an AttributeError.
2879- if self ._xmargin and scalex and self ._autoscaleXon :
2855+ if self ._xmargin and scalex and self .get_autoscalex_on () :
28802856 x_stickies = np .sort (np .concatenate ([
28812857 artist .sticky_edges .x
28822858 for ax in self ._shared_axes ["x" ].get_siblings (self )
28832859 if hasattr (ax , "_children" )
28842860 for artist in ax .get_children ()]))
2885- if self ._ymargin and scaley and self ._autoscaleYon :
2861+ if self ._ymargin and scaley and self .get_autoscaley_on () :
28862862 y_stickies = np .sort (np .concatenate ([
28872863 artist .sticky_edges .y
28882864 for ax in self ._shared_axes ["y" ].get_siblings (self )
@@ -2893,10 +2869,10 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
28932869 if self .get_yscale () == 'log' :
28942870 y_stickies = y_stickies [y_stickies > 0 ]
28952871
2896- def handle_single_axis (scale , autoscaleon , shared_axes , name ,
2897- axis , margin , stickies , set_bound ):
2872+ def handle_single_axis (
2873+ scale , shared_axes , name , axis , margin , stickies , set_bound ):
28982874
2899- if not (scale and autoscaleon ):
2875+ if not (scale and axis . _get_autoscale_on () ):
29002876 return # nothing to do...
29012877
29022878 shared = shared_axes .get_siblings (self )
@@ -2959,11 +2935,11 @@ def handle_single_axis(scale, autoscaleon, shared_axes, name,
29592935 # End of definition of internal function 'handle_single_axis'.
29602936
29612937 handle_single_axis (
2962- scalex , self ._autoscaleXon , self . _shared_axes ["x" ], 'x' ,
2963- self . xaxis , self . _xmargin , x_stickies , self .set_xbound )
2938+ scalex , self ._shared_axes ["x" ], 'x' , self . xaxis , self . _xmargin ,
2939+ x_stickies , self .set_xbound )
29642940 handle_single_axis (
2965- scaley , self ._autoscaleYon , self . _shared_axes ["y" ], 'y' ,
2966- self . yaxis , self . _ymargin , y_stickies , self .set_ybound )
2941+ scaley , self ._shared_axes ["y" ], 'y' , self . yaxis , self . _ymargin ,
2942+ y_stickies , self .set_ybound )
29672943
29682944 def _update_title_position (self , renderer ):
29692945 """
0 commit comments