@@ -439,6 +439,39 @@ def _check_box_return_type(self, returned, return_type, expected_keys=None,
439
439
else :
440
440
raise AssertionError
441
441
442
+ def _check_grid_settings (self , obj , kinds , kws = {}):
443
+ # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
444
+
445
+ import matplotlib as mpl
446
+
447
+ def is_grid_on ():
448
+ xoff = all (not g .gridOn for g in self .plt .gca ().xaxis .get_major_ticks ())
449
+ yoff = all (not g .gridOn for g in self .plt .gca ().yaxis .get_major_ticks ())
450
+ return not (xoff and yoff )
451
+
452
+ spndx = 1
453
+ for kind in kinds :
454
+ self .plt .subplot (1 ,4 * len (kinds ),spndx ); spndx += 1
455
+ mpl .rc ('axes' ,grid = False )
456
+ obj .plot (kind = kind , ** kws )
457
+ self .assertFalse (is_grid_on ())
458
+
459
+ self .plt .subplot (1 ,4 * len (kinds ),spndx ); spndx += 1
460
+ mpl .rc ('axes' ,grid = True )
461
+ obj .plot (kind = kind , grid = False , ** kws )
462
+ self .assertFalse (is_grid_on ())
463
+
464
+ if kind != 'pie' :
465
+ self .plt .subplot (1 ,4 * len (kinds ),spndx ); spndx += 1
466
+ mpl .rc ('axes' ,grid = True )
467
+ obj .plot (kind = kind , ** kws )
468
+ self .assertTrue (is_grid_on ())
469
+
470
+ #plt.figure()
471
+ self .plt .subplot (1 ,4 * len (kinds ),spndx ); spndx += 1
472
+ mpl .rc ('axes' ,grid = False )
473
+ obj .plot (kind = kind , grid = True , ** kws )
474
+ self .assertTrue (is_grid_on ())
442
475
443
476
@tm .mplskip
444
477
class TestSeriesPlots (TestPlotBase ):
@@ -1108,6 +1141,12 @@ def test_table(self):
1108
1141
_check_plot_works (self .series .plot , table = True )
1109
1142
_check_plot_works (self .series .plot , table = self .series )
1110
1143
1144
+ @slow
1145
+ def test_series_grid_settings (self ):
1146
+ # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
1147
+ self ._check_grid_settings (Series ([1 ,2 ,3 ]),
1148
+ plotting ._series_kinds + plotting ._common_kinds )
1149
+
1111
1150
1112
1151
@tm .mplskip
1113
1152
class TestDataFramePlots (TestPlotBase ):
@@ -3426,6 +3465,12 @@ def test_sharey_and_ax(self):
3426
3465
"y label is invisible but shouldn't" )
3427
3466
3428
3467
3468
+ @slow
3469
+ def test_df_grid_settings (self ):
3470
+ # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
3471
+ self ._check_grid_settings (DataFrame ({'a' :[1 ,2 ,3 ],'b' :[2 ,3 ,4 ]}),
3472
+ plotting ._dataframe_kinds , kws = {'x' :'a' ,'y' :'b' })
3473
+
3429
3474
3430
3475
@tm .mplskip
3431
3476
class TestDataFrameGroupByPlots (TestPlotBase ):
0 commit comments