@@ -439,6 +439,38 @@ 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
+ self .plt .subplot (1 ,4 * len (kinds ),spndx ); spndx += 1
471
+ mpl .rc ('axes' ,grid = False )
472
+ obj .plot (kind = kind , grid = True , ** kws )
473
+ self .assertTrue (is_grid_on ())
442
474
443
475
@tm .mplskip
444
476
class TestSeriesPlots (TestPlotBase ):
@@ -1108,6 +1140,12 @@ def test_table(self):
1108
1140
_check_plot_works (self .series .plot , table = True )
1109
1141
_check_plot_works (self .series .plot , table = self .series )
1110
1142
1143
+ @slow
1144
+ def test_series_grid_settings (self ):
1145
+ # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
1146
+ self ._check_grid_settings (Series ([1 ,2 ,3 ]),
1147
+ plotting ._series_kinds + plotting ._common_kinds )
1148
+
1111
1149
1112
1150
@tm .mplskip
1113
1151
class TestDataFramePlots (TestPlotBase ):
@@ -3426,6 +3464,12 @@ def test_sharey_and_ax(self):
3426
3464
"y label is invisible but shouldn't" )
3427
3465
3428
3466
3467
+ @slow
3468
+ def test_df_grid_settings (self ):
3469
+ # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
3470
+ self ._check_grid_settings (DataFrame ({'a' :[1 ,2 ,3 ],'b' :[2 ,3 ,4 ]}),
3471
+ plotting ._dataframe_kinds , kws = {'x' :'a' ,'y' :'b' })
3472
+
3429
3473
3430
3474
@tm .mplskip
3431
3475
class TestDataFrameGroupByPlots (TestPlotBase ):
0 commit comments