8000 BUG: Fix typo in view_limits() for MultipleLocator · matplotlib/matplotlib@b74e128 · GitHub
[go: up one dir, main page]

Skip to content

Commit b74e128

Browse files
committed
BUG: Fix typo in view_limits() for MultipleLocator
1 parent 1c55a25 commit b74e128

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
@@ -1750,7 +1750,7 @@ def view_limits(self, dmin, dmax):
17501750
"""
17511751
if rcParams['axes.autolimit_mode'] == 'round_numbers':
17521752
vmin = self._edge.le(dmin) * self._edge.step
1753-
vmax = self._base.ge(dmax) * self._edge.step
1753+
vmax = self._edge.ge(dmax) * self._edge.step
17541754
if vmin == vmax:
17551755
vmin -= 1
17561756
vmax += 1

0 commit comments

Comments
 (0)
0