@@ -275,15 +275,17 @@ class TestScalarFormatter(object):
275
275
276
276
use_offset_data = [True , False ]
277
277
278
+ # (sci_type, scilimits, lim, orderOfMag, fewticks)
278
279
scilimits_data = [
279
- (False , (0 , 0 ), (10.0 , 20.0 ), 0 ),
280
- (True , (- 2 , 2 ), (- 10 , 20 ), 0 ),
281
- (True , (- 2 , 2 ), (- 20 , 10 ), 0 ),
282
- (True , (- 2 , 2 ), (- 110 , 120 ), 2 ),
283
- (True , (- 2 , 2 ), (- 120 , 110 ), 2 ),
284
- (True , (- 2 , 2 ), (- .001 , 0.002 ), - 3 ),
285
- (True , (0 , 0 ), (- 1e5 , 1e5 ), 5 ),
286
- (True , (6 , 6 ), (- 1e5 , 1e5 ), 6 ),
280
+ (False , (0 , 0 ), (10.0 , 20.0 ), 0 , False ),
281
+ (True , (- 2 , 2 ), (- 10 , 20 ), 0 , False ),
282
+ (True , (- 2 , 2 ), (- 20 , 10 ), 0 , False ),
283
+ (True , (- 2 , 2 ), (- 110 , 120 ), 2 , False ),
284
+ (True , (- 2 , 2 ), (- 120 , 110 ), 2 , False ),
285
+ (True , (- 2 , 2 ), (- .001 , 0.002 ), - 3 , False ),
286
+ (True , (- 7 , 7 ), (0.18e10 , 0.83e10 ), 9 , True ),
287
+ (True , (0 , 0 ), (- 1e5 , 1e5 ), 5 , False ),
288
+ (True , (6 , 6 ), (- 1e5 , 1e5 ), 6 , False ),
287
289
]
288
290
289
291
@pytest .mark .parametrize ('left, right, offset' , offset_data )
@@ -316,14 +318,18 @@ def test_use_offset(self, use_offset):
316
318
assert use_offset == tmp_form .get_useOffset ()
317
319
318
320
@pytest .mark .parametrize (
319
- 'sci_type, scilimits, lim, orderOfMag' , scilimits_data )
320
- def test_scilimits (self , sci_type , scilimits , lim , orderOfMag ):
321
+ 'sci_type, scilimits, lim, orderOfMag, fewticks' , scilimits_data )
322
+ def test_scilimits (self , sci_type , scilimits , lim , orderOfMag ,
323
+ fewticks ):
321
324
tmp_form = mticker .ScalarFormatter ()
322
325
tmp_form .set_scientific (sci_type )
323
326
tmp_form .set_powerlimits (scilimits )
324
327
fig , ax = plt .subplots ()
325
328
ax .yaxis .set_major_formatter (tmp_form )
326
329
ax .set_ylim (* lim )
330
+ if fewticks :
331
+ ax .yaxis .set_major_locator (mticker .MaxNLocator (4 ))
332
+
327
333
tmp_form .set_locs (ax .yaxis .get_majorticklocs ())
328
334
assert orderOfMag == tmp_form .orderOfMagnitude
329
335
0 commit comments