File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Original file line number Diff line number Diff line change 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 ()))
Original file line number Diff line number Diff line change @@ -2903,7 +2903,7 @@ def __call__(self):
2903
2903
_api .warn_external ('AutoMinorLocator does not work on logarithmic scales' )
2904
2904
return []
2905
2905
2906
- majorlocs = self .axis .get_majorticklocs ()
2906
+ majorlocs = np . unique ( self .axis .get_majorticklocs () )
2907
2907
if len (majorlocs ) < 2 :
2908
2908
# Need at least two major ticks to find minor tick locations.
2909
2909
# TODO: Figure out a way to still be able to display minor ticks with less
You can’t perform that action at this time.
0 commit comments