@@ -1224,6 +1224,7 @@ def cla(self):
1224
1224
self .set_xlim (0 , 1 )
1225
1225
except TypeError :
1226
1226
pass
1227
+ self .set_autoscalex_on (True )
1227
1228
if self ._sharey is not None :
1228
1229
self .sharey (self ._sharey )
1229
1230
else :
@@ -1232,17 +1233,14 @@ def cla(self):
1232
1233
self .set_ylim (0 , 1 )
1233
1234
except TypeError :
1234
1235
pass
1236
+ self .set_autoscaley_on (True )
1235
1237
1236
1238
# update the minor locator for x and y axis based on rcParams
1237
1239
if mpl .rcParams ['xtick.minor.visible' ]:
1238
1240
self .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
1239
1241
if mpl .rcParams ['ytick.minor.visible' ]:
1240
1242
self .yaxis .set_minor_locator (mticker .AutoMinorLocator ())
1241
1243
1242
- if self ._sharex is None :
1243
- self ._autoscaleXon = True
1244
- if self ._sharey is None :
1245
- self ._autoscaleYon = True
1246
1244
self ._xmargin = mpl .rcParams ['axes.xmargin' ]
1247
1245
self ._ymargin = mpl .rcParams ['axes.ymargin' ]
1248
1246
self ._tight = None
@@ -2573,17 +2571,15 @@ def in_axes(self, mouseevent):
2573
2571
"""
2574
2572
return self .patch .contains (mouseevent )[0 ]
2575
2573
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
+
2576
2579
def get_autoscale_on (self ):
2577
2580
"""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 ())
2587
2583
2588
2584
def set_autoscale_on (self , b ):
2589
2585
"""
@@ -2594,30 +2590,8 @@ def set_autoscale_on(self, b):
2594
2590
----------
2595
2591
b : bool
2596
2592
"""
2597
- self ._autoscaleXon
A3DB
= 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 )
2621
2595
2622
2596
@property
2623
2597
def use_sticky_edges (self ):
@@ -2810,14 +2784,16 @@ def autoscale(self, enable=True, axis='both', tight=None):
2810
2784
scalex = True
2811
2785
scaley = True
2812
2786
else :
2813
- scalex = False
2814
- scaley = False
2815
2787
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
2818
2792
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
2821
2797
if tight and scalex :
2822
2798
self ._xmargin = 0
2823
2799
if tight and scaley :
@@ -2876,13 +2852,13 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
2876
2852
# called very early in the Axes init process (e.g., for twin Axes)
2877
2853
# when these attributes don't even exist yet, in which case
2878
2854
# `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 () :
2880
2856
x_stickies = np .sort (np .concatenate ([
2881
2857
artist .sticky_edges .x
2882
2858
for ax in self ._shared_axes ["x" ].get_siblings (self )
2883
2859
if hasattr (ax , "_children" )
2884
2860
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 () :
2886
2862
y_stickies = np .sort (np .concatenate ([
2887
2863
artist .sticky_edges .y
2888
2864
for ax in self ._shared_axes ["y" ].get_siblings (self )
@@ -2893,10 +2869,10 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
2893
2869
if self .get_yscale () == 'log' :
2894
2870
y_stickies = y_stickies [y_stickies > 0 ]
2895
2871
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 ):
2898
2874
2899
- if not (scale and autoscaleon ):
2875
+ if not (scale and axis . _get_autoscale_on () ):
2900
2876
return # nothing to do...
2901
2877
2902
2878
shared = shared_axes .get_siblings (self )
@@ -2959,11 +2935,11 @@ def handle_single_axis(scale, autoscaleon, shared_axes, name,
2959
2935
# End of definition of internal function 'handle_single_axis'.
2960
2936
2961
2937
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 )
2964
2940
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 )
2967
2943
2968
2944
def _update_title_position (self , renderer ):
2969
2945
"""
0 commit comments