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 7afef94

Browse filesBrowse files
authored
Merge pull request #12313 from dopplershift/fix-limits
BUG: Fix typo in view_limits() for MultipleLocator
2 parents 1c55a25 + b74e128 commit 7afef94
Copy full SHA for 7afef94

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
@@ -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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.