Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35e30d0

Browse files
committed
Force autoscaling immediately after setting a scale.
1 parent cf2ef39 commit 35e30d0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,6 @@ def set_xscale(self, value, **kwargs):
32523252
- `matplotlib.scale.SymmetricalLogScale`
32533253
- `matplotlib.scale.LogitScale`
32543254
3255-
32563255
Notes
32573256
-----
32583257
By default, Matplotlib supports the above mentioned scales.
@@ -3265,7 +3264,9 @@ def set_xscale(self, value, **kwargs):
32653264
ax.xaxis._set_scale(value, **kwargs)
32663265
ax._update_transScale()
32673266
ax.stale = True
3268-
self._request_autoscale_view(scaley=False)
3267+
# Force autoscaling now, to take advantage of the scale locator's
3268+
# nonsingular() before it possibly gets swapped out by the user.
3269+
self.autoscale_view(scaley=False)
32693270

32703271
@cbook._make_keyword_only("3.2", "minor")
32713272
def get_xticks(self, minor=False):
@@ -3637,7 +3638,6 @@ def set_yscale(self, value, **kwargs):
36373638
- `matplotlib.scale.SymmetricalLogScale`
36383639
- `matplotlib.scale.LogitScale`
36393640
3640-
36413641
Notes
36423642
-----
36433643
By default, Matplotlib supports the above mentioned scales.
@@ -3650,7 +3650,9 @@ def set_yscale(self, value, **kwargs):
36503650
ax.yaxis._set_scale(value, **kwargs)
36513651
ax._update_transScale()
36523652
ax.stale = True
3653-
self._request_autoscale_view(scalex=False)
3653+
# Force autoscaling now, to take advantage of the scale locator's
3654+
# nonsingular() before it possibly gets swapped out by the user.
3655+
self.autoscale_view(scalex=False)
36543656

36553657
@cbook._make_keyword_only("3.2", "minor")
36563658
def get_yticks(self, minor=False):

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,7 @@ def test_log_scales():
21732173
def test_log_scales_no_data():
21742174
_, ax = plt.subplots()
21752175
ax.set(xscale="log", yscale="log")
2176+
ax.xaxis.set_major_locator(mticker.MultipleLocator(1))
21762177
assert ax.get_xlim() == ax.get_ylim() == (1, 10)
21772178

21782179

0 commit comments

Comments
 (0)