@@ -99,9 +99,7 @@ def test_basic(self):
99
99
# NB: the following values are assuming that *xlim* is [0, 5]
100
100
params = [
101
101
(0 , 0 ), # no major tick => no minor tick either
102
- (1 , 0 ), # a single major tick => no minor tick
103
- (2 , 4 ), # 1 "nice" major step => 1*5 minor **divisions**
104
- (3 , 6 ) # 2 "not nice" major steps => 2*4 minor **divisions**
102
+ (1 , 0 ) # a single major tick => no minor tick
105
103
]
106
104
107
105
@pytest .mark .parametrize ('nb_majorticks, expected_nb_minorticks' , params )
@@ -116,6 +114,32 @@ def test_low_number_of_majorticks(
116
114
ax .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
117
115
assert len (ax .xaxis .get_minorticklocs ()) == expected_nb_minorticks
118
116
117
+ majorstep_minordivisions = [(1 , 5 ),
118
+ (2 , 4 ),
119
+ (2.5 , 5 ),
120
+ (5 , 5 ),
121
+ (10 , 5 )]
122
+
123
+ # This test is meant to verify the parameterization for
124
+ # test_number_of_minor_ticks
125
+ def test_using_all_default_major_steps (self ):
126
+ with matplotlib .rc_context ({'_internal.classic_mode' : False }):
127
+ majorsteps = [x [0 ] for x in self .majorstep_minordivisions ]
128
+ assert np .allclose (majorsteps , mticker .AutoLocator ()._steps )
129
+
130
+ @pytest .mark .parametrize ('major_step, expected_nb_minordivisions' ,
131
+ majorstep_minordivisions )
132
+ def test_number_of_minor_ticks (
133
+ self , major_step , expected_nb_minordivisions ):
134
+ fig , ax = plt .subplots ()
135
+ xlims = (0 , major_step )
136
+ ax .set_xlim (* xlims )
137
+ ax .set_xticks (xlims )
138
+ ax .minorticks_on ()
139
+ ax .xaxis .set_minor_locator (mticker .AutoMinorLocator ())
140
+ nb_minor_divisions = len (ax .xaxis .get_minorticklocs ()) + 1
141
+ assert nb_minor_divisions == expected_nb_minordivisions
142
+
119
143
limits = [(0 , 1.39 ), (0 , 0.139 ),
120
144
(0 , 0.11e-19 ), (0 , 0.112e-12 ),
121
145
(- 2.0e-07 , - 3.3e-08 ), (1.20e-06 , 1.42e-06 ),
0 commit comments