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 44677ff

Browse filesBrowse files
committed
add test for AutoMinorLocator with low number of major ticks
1 parent 208e982 commit 44677ff
Copy full SHA for 44677ff

File tree

Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/tests/test_ticker.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ def test_basic(self):
8080
0.95, 1, 1.05, 1.1, 1.15, 1.25, 1.3, 1.35])
8181
assert_almost_equal(ax.xaxis.get_ticklocs(minor=True), test_value)
8282

83+
# NB: the following values are assuming that *xlim* is [0, 5]
84+
params = [
85+
(0, 0), # no major tick => no minor tick either
86+
(1, 0), # a single major tick => no minor tick
87+
(2, 4), # 1 "nice" major step => 1*5 minor **divisions**
88+
(3, 6) # 2 "not nice" major steps => 2*4 minor **divisions**
89+
]
90+
91+
@pytest.mark.parametrize('nb_majorticks, expected_nb_minorticks', params)
92+
def test_low_number_of_majorticks(
93+
self, nb_majorticks, expected_nb_minorticks):
94+
# This test is related to issue #8804
95+
fig, ax = plt.subplots()
96+
xlims = (0, 5) # easier to test the different code paths
97+
ax.set_xlim(*xlims)
98+
ax.set_xticks(np.linspace(xlims[0], xlims[1], nb_majorticks))
99+
ax.minorticks_on()
100+
ax.xaxis.set_minor_locator(mticker.AutoMinorLocator())
101+
assert len(ax.xaxis.get_minorticklocs()) == expected_nb_minorticks
102+
83103

84104
class TestLogLocator(object):
85105
def test_basic(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.