|
12 | 12 | import matplotlib.pyplot as plt
|
13 | 13 | import matplotlib.ticker as mticker
|
14 | 14 |
|
| 15 | +import random |
| 16 | + |
15 | 17 |
|
16 | 18 | class TestMaxNLocator:
|
17 | 19 | basic_data = [
|
@@ -1789,3 +1791,31 @@ def test_set_offset_string(formatter):
|
1789 | 1791 | assert formatter.get_offset() == ''
|
1790 | 1792 | formatter.set_offset_string('mpl')
|
1791 | 1793 | assert formatter.get_offset() == 'mpl'
|
| 1794 | + |
| 1795 | + |
| 1796 | +def test_minorticks_on_multi_fig(): |
| 1797 | + """ |
| 1798 | + Turning on minor gridlines in a multi-Axes Figure |
| 1799 | + that contains more than one boxplot and shares the x-axis |
| 1800 | + should not raise an exception. |
| 1801 | + """ |
| 1802 | + fig, ax = plt.subplots(sharex=True, ncols=2, nrows=2) |
| 1803 | + |
| 1804 | + def values(): |
| 1805 | + return [random.random() for _ in range(9)] |
| 1806 | + |
| 1807 | + for x in range(3): |
| 1808 | + ax[0, 0].boxplot(values(), positions=[x]) |
| 1809 | + ax[0, 1].boxplot(values(), positions=[x]) |
| 1810 | + ax[1, 0].boxplot(values(), positions=[x]) |
| 1811 | + ax[1, 1].boxplot(values(), positions=[x]) |
| 1812 | + |
| 1813 | + for a in ax.flatten(): |
| 1814 | + a.grid(which="major") |
| 1815 | + a.grid(which="minor", linestyle="--") |
| 1816 | + a.minorticks_on() |
| 1817 | + fig.canvas.draw() |
| 1818 | + |
| 1819 | + assert all(a.get_xgridlines() for a in ax.flatten()) |
| 1820 | + assert all((isinstance(a.xaxis.get_minor_locator(), mpl.ticker.AutoMinorLocator) |
| 1821 | + for a in ax.flatten())) |
0 commit comments