|
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 = [
|
@@ -1796,3 +1798,31 @@ def test_set_offset_string(formatter):
|
1796 | 1798 | assert formatter.get_offset() == ''
|
1797 | 1799 | formatter.set_offset_string('mpl')
|
1798 | 1800 | assert formatter.get_offset() == 'mpl'
|
| 1801 | + |
| 1802 | + |
| 1803 | +def test_minorticks_on_multi_fig(): |
| 1804 | + """ |
| 1805 | + Turning on minor gridlines in a multi-Axes Figure |
| 1806 | + that contains more than one boxplot and shares the x-axis |
| 1807 | + should not raise an exception. |
| 1808 | + """ |
| 1809 | + fig, ax = plt.subplots(sharex=True, ncols=2, nrows=2) |
| 1810 | + |
| 1811 | + def values(): |
| 1812 | + return [random.random() for _ in range(9)] |
| 1813 | + |
| 1814 | + for x in range(3): |
| 1815 | + ax[0, 0].boxplot(values(), positions=[x]) |
| 1816 | + ax[0, 1].boxplot(values(), positions=[x]) |
| 1817 | + ax[1, 0].boxplot(values(), positions=[x]) |
| 1818 | + ax[1, 1].boxplot(values(), positions=[x]) |
| 1819 | + |
| 1820 | + for a in ax.flatten(): |
| 1821 | + a.grid(which="major") |
| 1822 | + a.grid(which="minor", linestyle="--") |
| 1823 | + a.minorticks_on() |
| 1824 | + fig.canvas.draw() |
| 1825 | + |
| 1826 | + assert all(a.get_xgridlines() for a in ax.flatten()) |
| 1827 | + assert all((isinstance(a.xaxis.get_minor_locator(), mpl.ticker.AutoMinorLocator) |
| 1828 | + for a in ax.flatten())) |
0 commit comments