8000 Merge pull request #12315 from meeseeksmachine/auto-backport-of-pr-12… · matplotlib/matplotlib@b5d50c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b5d50c0

Browse files
authored
Merge pull request #12315 from meeseeksmachine/auto-backport-of-pr-12313-on-v3.0.x
Backport PR #12313 on branch v3.0.x (BUG: Fix typo in view_limits() for MultipleLocator)
2 parents 5fa5cab + b516dd8 commit b5d50c0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ def test_basic(self):
5959
9.441, 12.588])
6060
assert_almost_equal(loc.tick_values(-7, 10), test_value)
6161

62+
def test_view_limits(self):
63+
"""
64+
Test basic behavior of view limits.
65+
"""
66+
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
67+
loc = mticker.MultipleLocator(base=3.147)
68+
assert_almost_equal(loc.view_limits(-5, 5), (-5, 5))
69+
70+
def test_view_limits_round_numbers(self):
71+
"""
72+
Test that everything works properly with 'round_numbers' for auto
73+
limit.
74+
"""
75+
with matplotlib.rc_context({'axes.autolimit_mode': 'round_numbers'}):
76+
loc = mticker.MultipleLocator(base=3.147)
77+
assert_almost_equal(loc.view_limits(-4, 4), (-6.294, 6.294))
78+
6279
def test_set_params(self):
6380
"""
6481
Create multiple locator with 0.7 base, and change it to something else.

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ def view_limits(self, dmin, dmax):
17421742
"""
17431743
if rcParams['axes.autolimit_mode'] == 'round_numbers':
17441744
vmin = self._edge.le(dmin) * self._edge.step
1745-
vmax = self._base.ge(dmax) * self._edge.step
1745+
vmax = self._edge.ge(dmax) * self._edge.step
17461746
if vmin == vmax:
17471747
vmin -= 1
17481748
vmax += 1

0 commit comments

Comments
 (0)
0