@@ -439,6 +439,39 @@ def _check_box_return_type(self, returned, return_type, expected_keys=None,
439439 else :
440440 raise AssertionError
441441
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 ())
442475
443476@tm .mplskip
444477class TestSeriesPlots (TestPlotBase ):
@@ -1108,6 +1141,12 @@ def test_table(self):
11081141 _check_plot_works (self .series .plot , table = True )
11091142 _check_plot_works (self .series .plot , table = self .series )
11101143
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+
11111150
11121151@tm .mplskip
11131152class TestDataFramePlots (TestPlotBase ):
@@ -3426,6 +3465,12 @@ def test_sharey_and_ax(self):
34263465 "y label is invisible but shouldn't" )
34273466
34283467
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+
34293474
34303475@tm .mplskip
34313476class TestDataFrameGroupByPlots (TestPlotBase ):
0 commit comments