@@ -2409,17 +2409,9 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
24092409 dl .extend (y_finite )
24102410
24112411 bb = mtransforms .BboxBase .union (dl )
2412- # fall back on the viewlimits if this is not finite:
2413- vl = None
2414- if not np .isfinite (bb .intervalx ).all ():
2415- vl = mtransforms .BboxBase .union ([ax .viewLim for ax in shared ])
2416- bb .intervalx = vl .intervalx
2417- if not np .isfinite (bb .intervaly ).all ():
2418- if vl is None :
2419- vl = mtransforms .BboxBase .union (
2420- [ax .viewLim for ax in shared ])
2421- bb .intervaly = vl .intervaly
24222412 x0 , x1 = getattr (bb , interval )
2413+ # If x0 and x1 are non finite, use the locator to figure out
2414+ # default limits.
24232415 locator = axis .get_major_locator ()
24242416 x0 , x1 = locator .nonsingular (x0 , x1 )
24252417
@@ -3260,20 +3252,26 @@ def set_xscale(self, value, **kwargs):
32603252 - `matplotlib.scale.SymmetricalLogScale`
32613253 - `matplotlib.scale.LogitScale`
32623254
3263-
32643255 Notes
32653256 -----
32663257 By default, Matplotlib supports the above mentioned scales.
32673258 Additionally, custom scales may be registered using
32683259 `matplotlib.scale.register_scale`. These scales can then also
32693260 be used here.
32703261 """
3262+ old_default_lims = (self .xaxis .get_major_locator ()
3263+ .nonsingular (- np .inf , np .inf ))
32713264 g = self .get_shared_x_axes ()
32723265 for ax in g .get_siblings (self ):
32733266 ax .xaxis ._set_scale (value , ** kwargs )
32743267 ax ._update_transScale ()
32753268 ax .stale = True
3276- self ._request_autoscale_view (scaley = False )
3269+ new_default_lims = (self .xaxis .get_major_locator ()
3270+ .nonsingular (- np .inf , np .inf ))
3271+ if old_default_lims != new_default_lims :
3272+ # Force autoscaling now, to take advantage of the scale locator's
3273+ # nonsingular() before it possibly gets swapped out by the user.
3274+ self .autoscale_view (scaley = False )
32773275
32783276 @cbook ._make_keyword_only ("3.2" , "minor" )
32793277 def get_xticks (self , minor = False ):
@@ -3645,20 +3643,26 @@ def set_yscale(self, value, **kwargs):
36453643 - `matplotlib.scale.SymmetricalLogScale`
36463644 - `matplotlib.scale.LogitScale`
36473645
3648-
36493646 Notes
36503647 -----
36513648 By default, Matplotlib supports the above mentioned scales.
36523649 Additionally, custom scales may be registered using
36533650 `matplotlib.scale.register_scale`. These scales can then also
36543651 be used here.
36553652 """
3653+ old_default_lims = (self .yaxis .get_major_locator ()
3654+ .nonsingular (- np .inf , np .inf ))
36563655 g = self .get_shared_y_axes ()
36573656 for ax in g .get_siblings (self ):
36583657 ax .yaxis ._set_scale (value , ** kwargs )
36593658 ax ._update_transScale ()
36603659 ax .stale = True
3661- self ._request_autoscale_view (scalex = False )
3660+ new_default_lims = (self .yaxis .get_major_locator ()
3661+ .nonsingular (- np .inf , np .inf ))
3662+ if old_default_lims != new_default_lims :
3663+ # Force autoscaling now, to take advantage of the scale locator's
3664+ # nonsingular() before it possibly gets swapped out by the user.
3665+ self .autoscale_view (scalex = False )
36623666
36633667 @cbook ._make_keyword_only ("3.2" , "minor" )
36643668 def get_yticks (self , minor = False ):
0 commit comments