@@ -813,6 +813,7 @@ def _maybe_right_yaxis(self, ax):
813813 new_ax ._get_lines .color_cycle = orig_ax ._get_lines .color_cycle
814814
815815 orig_ax .right_ax , new_ax .left_ax = new_ax , orig_ax
816+ new_ax .right_ax = new_ax
816817
817818 if len (orig_ax .get_lines ()) == 0 : # no data on left y
818819 orig_ax .get_yaxis ().set_visible (False )
@@ -1573,6 +1574,7 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
15731574 For line plots, use log scaling on y axis
15741575 secondary_y : boolean or sequence of ints, default False
15751576 If True then y-axis will be on the right
1577+ figsize : a tuple (width, height) in inches
15761578 kwds : keywords
15771579 Options to pass to matplotlib plotting method
15781580
@@ -1588,7 +1590,18 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
15881590 elif kind == 'kde' :
15891591 klass = KdePlot
15901592
1591- if ax is None :
1593+ """
1594+ If no axis is specified, we check whether there are existing figures.
1595+ If so, we get the current axis and check whether yaxis ticks are on the
1596+ right. Ticks for the plot of the series will be on the right unless
1597+ there is at least one axis with ticks on the left.
1598+
1599+ If we do not check for whether there are existing figures, _gca() will
1600+ create a figure with the default figsize, causing the figsize= parameter to
1601+ be ignored.
1602+ """
1603+ import matplotlib .pyplot as plt
1604+ if ax is None and len (plt .get_fignums ()) > 0 :
15921605 ax = _gca ()
15931606 if ax .get_yaxis ().get_ticks_position ().strip ().lower () == 'right' :
15941607 fig = _gcf ()
@@ -1612,7 +1625,8 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
16121625 plot_obj .generate ()
16131626 plot_obj .draw ()
16141627
1615- return plot_obj .ax
1628+ # plot_obj.ax is None if we created the first figure
1629+ return plot_obj .axes [0 ]
16161630
16171631
16181632def boxplot (data , column = None , by = None , ax = None , fontsize = None ,
0 commit comments