@@ -211,6 +211,60 @@ def test_additional(self, lim, ref):
211211
212212 assert_almost_equal (ax .yaxis .get_ticklocs (minor = True ), ref )
213213
214+ @pytest .mark .parametrize ('use_rcparam' , [False , True ])
215+ @pytest .mark .parametrize (
216+ 'lim, ref' , [
217+ ((0 , 1.39 ),
218+ [0.05 , 0.1 , 0.15 , 0.25 , 0.3 , 0.35 , 0.45 , 0.5 , 0.55 , 0.65 , 0.7 ,
219+ 0.75 , 0.85 , 0.9 , 0.95 , 1.05 , 1.1 , 1.15 , 1.25 , 1.3 , 1.35 ]),
220+ ((0 , 0.139 ),
221+ [0.005 , 0.01 , 0.015 , 0.025 , 0.03 , 0.035 , 0.045 , 0.05 , 0.055 ,
222+ 0.065 , 0.07 , 0.075 , 0.085 , 0.09 , 0.095 , 0.105 , 0.11 , 0.115 ,
223+ 0.125 , 0.13 , 0.135 ]),
224+ ])
225+ def test_number_of_minor_ticks_auto (self , lim , ref , use_rcparam ):
226+ if use_rcparam :
227+ context = {'xtick.minor.ndivs' : 'auto' , 'ytick.minor.ndivs' : 'auto' }
228+ kwargs = {}
229+ else :
230+ context = {}
231+ kwargs = {'n' : 'auto' }
232+
233+ with mpl .rc_context (context ):
234+ fig , ax = plt .subplots ()
235+ ax .set_xlim (* lim )
236+ ax .set_ylim (* lim )
237+ ax .xaxis .set_minor_locator (mticker .AutoMinorLocator (** kwargs ))
238+ ax .yaxis .set_minor_locator (mticker .AutoMinorLocator (** kwargs ))
239+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), ref )
240+ assert_almost_equal (ax .yaxis .get_ticklocs (minor = True ), ref )
241+
242+ @pytest .mark .parametrize ('use_rcparam' , [False , True ])
243+ @pytest .mark .parametrize (
244+ 'n, lim, ref' , [
245+ (2 , (0 , 4 ), [0.5 , 1.5 , 2.5 , 3.5 ]),
246+ (4 , (0 , 2 ), [0.25 , 0.5 , 0.75 , 1.25 , 1.5 , 1.75 ]),
247+ (10 , (0 , 1 ), [0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 ]),
248+ ])
249+ def test_number_of_minor_ticks_int (self , n , lim , ref , use_rcparam ):
250+ if use_rcparam :
251+ context = {'xtick.minor.ndivs' : n , 'ytick.minor.ndivs' : n }
252+ kwargs = {}
253+ else :
254+ context = {}
255+ kwargs = {'n' : n }
256+
257+ with mpl .rc_context (context ):
258+ fig , ax = plt .subplots ()
259+ ax .set_xlim (* lim )
260+ ax .set_ylim (* lim )
261+ ax .xaxis .set_major_locator (mticker .MultipleLocator (1 ))
262+ ax .xaxis .set_minor_locator (mticker .AutoMinorLocator (** kwargs ))
263+ ax .yaxis .set_major_locator (mticker .MultipleLocator (1 ))
264+ ax .yaxis .set_minor_locator (mticker .AutoMinorLocator (** kwargs ))
265+ assert_almost_equal (ax .xaxis .get_ticklocs (minor = True ), ref )
266+ assert_almost_equal (ax .yaxis .get_ticklocs (minor = True ), ref )
267+
214268
215269class TestLogLocator :
216270 def test_basic (self ):
0 commit comments