Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5d50c0

Browse filesBrowse 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
Copy full SHA for b5d50c0

File tree

Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+17Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+1-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.