@@ -276,7 +276,7 @@ class MPLPlot(object):
276
276
277
277
def __init__ (self , data , kind = None , by = None , subplots = False , sharex = True ,
278
278
sharey = False , use_index = True ,
279
- figsize = None , grid = True , legend = True , rot = None ,
279
+ figsize = None , grid = None , legend = True , rot = None ,
280
280
ax = None , fig = None , title = None , xlim = None , ylim = None ,
281
281
xticks = None , yticks = None ,
282
282
sort_columns = False , fontsize = None ,
@@ -304,6 +304,9 @@ def __init__(self, data, kind=None, by=None, subplots=False, sharex=True,
304
304
self .fontsize = fontsize
305
305
self .rot = rot
306
306
307
+ if grid is None :
308
+ grid = False if secondary_y else True
309
+
307
310
self .grid = grid
308
311
self .legend = legend
309
312
@@ -377,13 +380,15 @@ def _setup_subplots(self):
377
380
if self .ax is None :
378
381
fig = self .plt .figure (figsize = self .figsize )
379
382
ax = fig .add_subplot (111 )
380
- if self .secondary_y :
383
+ ypos = ax .get_yaxis ().get_ticks_position ().strip ().lower ()
384
+ if self .secondary_y and ypos != 'right' :
381
385
ax = ax .twinx ()
382
386
self .ax = ax
383
387
else :
384
388
ax = self .ax
385
389
fig = self .ax .get_figure ()
386
- if self .secondary_y :
390
+ ypos = ax .get_yaxis ().get_ticks_position ().strip ().lower ()
391
+ if self .secondary_y and ypos != 'right' :
387
392
ax = ax .twinx ()
388
393
self .ax = ax
389
394
@@ -796,12 +801,12 @@ class HistPlot(MPLPlot):
796
801
797
802
def plot_frame (frame = None , subplots = False , sharex = True , sharey = False ,
798
803
use_index = True ,
799
- figsize = None , grid = True , legend = True , rot = None ,
804
+ figsize = None , grid = False , legend = True , rot = None ,
800
805
ax = None , title = None ,
801
806
xlim = None , ylim = None , logy = False ,
802
807
xticks = None , yticks = None ,
803
808
kind = 'line' ,
804
- sort_columns = False , fontsize = None , ** kwds ):
809
+ sort_columns = False , fontsize = None , secondary_y = False , ** kwds ):
805
810
"""
806
811
Make line or bar plot of DataFrame's series with the index on the x-axis
807
812
using matplotlib / pylab.
@@ -874,7 +879,8 @@ def plot_frame(frame=None, subplots=False, sharex=True, sharey=False,
874
879
875
880
def plot_series (series , label = None , kind = 'line' , use_index = True , rot = None ,
876
881
xticks = None , yticks = None , xlim = None , ylim = None ,
877
- ax = None , style = None , grid = True , logy = False , ** kwds ):
882
+ ax = None , style = None , grid = None , logy = False , secondary_y = False ,
883
+ ** kwds ):
878
884
"""
879
885
Plot the input series with the index on the x-axis using matplotlib
880
886
@@ -931,7 +937,8 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
931
937
plot_obj = klass (series , kind = kind , rot = rot , logy = logy ,
932
938
ax = ax , use_index = use_index , style = style ,
933
939
xticks = xticks , yticks = yticks , xlim = xlim , ylim = ylim ,
934
- legend = False , grid = grid , label = label , ** kwds )
940
+ legend = False , grid = grid , label = label ,
941
+ secondary_y = secondary_y , ** kwds )
935
942
936
943
plot_obj .generate ()
937
944
plot_obj .draw ()
0 commit comments