8000 Backport of pr 27647 on v3.8.x by dstansby · Pull Request #27661 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport of pr 27647 on v3.8.x #27661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,3 +1797,24 @@ def test_set_offset_string(formatter):
assert formatter.get_offset() == ''
formatter.set_offset_string('mpl')
assert formatter.get_offset() == 'mpl'


def test_minorticks_on_multi_fig():
"""
Turning on minor gridlines in a multi-Axes Figure
that contains more than one boxplot and shares the x-axis
should not raise an exception.
"""
fig, ax = plt.subplots()

ax.boxplot(np.arange(10), positions=[0])
ax.boxplot(np.arange(10), positions=[0])
ax.boxplot(np.arange(10), positions=[1])

ax.grid(which="major")
ax.grid(which="minor")
ax.minorticks_on()
fig.draw_without_rendering()

assert ax.get_xgridlines()
assert isinstance(ax.xaxis.get_minor_locator(), mpl.ticker.AutoMinorLocator)
2 changes: 1 addition & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ def __call__(self):
'logarithmic scale')
return []

majorlocs = self.axis.get_majorticklocs()
majorlocs = np.unique(self.axis.get_majorticklocs())
try:
majorstep = majorlocs[1] - majorlocs[0]
except IndexError:
Expand Down
0