@@ -1038,17 +1038,21 @@ class HistPlot(MPLPlot):
1038
1038
pass
1039
1039
1040
1040
1041
- def plot_frame (frame = None , subplots = False , sharex = True , sharey = False ,
1042
- use_index = True , figsize = None , grid = False , legend = True , rot = None ,
1043
- ax = None , style = None , title = None , xlim = None , ylim = None , logy = False ,
1044
- xticks = None , yticks = None , kind = 'line' , sort_columns = False ,
1045
- fontsize = None , secondary_y = False , ** kwds ):
1041
+ def plot_frame (frame = None , x = None , y = None , subplots = False , sharex = True ,
1042
+ sharey = False , use_index = True , figsize = None , grid = False ,
1043
+ legend = True , rot = None , ax = None , style = None , title = None , xlim = None ,
1044
+ ylim = None , logy = False , xticks = None , yticks = None , kind = 'line' ,
1045
+ sort_columns = False , fontsize = None , secondary_y = False , ** kwds ):
1046
+
1046
1047
"""
1047
1048
Make line or bar plot of DataFrame's series with the index on the x-axis
1048
1049
using matplotlib / pylab.
1049
1050
1050
1051
Parameters
1051
1052
----------
1053
+ x : int or str, default None
1054
+ y : int or str, default None
1055
+ Allows plotting of one column versus another
1052
1056
subplots : boolean, default False
1053
1057
Make separate subplots for each time series
1054
1058
sharex : boolean, default True
@@ -1104,6 +1108,20 @@ def plot_frame(frame=None, subplots=False, sharex=True, sharey=False,
1104
1108
else :
1105
1109
raise ValueError ('Invalid chart type given %s' % kind )
1106
1110
1111
+ if isinstance (x , int ):
1112
+ x = frame .columns [x ]
1113
+ if x is not None :
1114
+ frame = frame .set_index (x ).sort_index ()
1115
+
1116
+ if isinstance (y , int ):
1117
+ y = frame .columns [y ]
1118
+ if y is not None :
1119
+ return plot_series (frame [y ], label = y , kind = kind , use_index = True ,
1120
+ rot = rot , xticks = xticks , yticks = yticks ,
1121
+ xlim = xlim , ylim = ylim , ax = ax , style = style ,
1122
+ grid = grid , logy = logy , secondary_y = secondary_y ,
1123
+ ** kwds )
1124
+
1107
1125
plot_obj = klass (frame , kind = kind , subplots = subplots , rot = rot ,
1108
1126
legend = legend , ax = ax , style = style , fontsize = fontsize ,
1109
1127
use_index = use_index , sharex = sharex , sharey = sharey ,
@@ -1118,7 +1136,6 @@ def plot_frame(frame=None, subplots=False, sharex=True, sharey=False,
1118
1136
else :
1119
1137
return plot_obj .axes [0 ]
1120
1138
1121
-
1122
1139
def plot_series (series , label = None , kind = 'line' , use_index = True , rot = None ,
1123
1140
xticks = None , yticks = None , xlim = None , ylim = None ,
1124
1141
ax = None , style = None , grid = None , logy = False , secondary_y = False ,
0 commit comments