@@ -900,8 +900,8 @@ def fillna(self, value=None, method='pad'):
900
900
#-------------------------------------------------------------------------------
901
901
# Miscellaneous
902
902
903
- def plot (self , label = None , kind = 'line' , rot = 30 , axes = None , style = '-' ,
904
- ** kwds ): # pragma: no cover
903
+ def plot (self , label = None , kind = 'line' , use_index = True , rot = 30 , ax = None ,
904
+ style = '-' , ** kwds ): # pragma: no cover
905
905
"""
906
906
Plot the input series with the index on the x-axis using
907
907
matplotlib / pylab.
@@ -911,6 +911,7 @@ def plot(self, label=None, kind='line', rot=30, axes=None, style='-',
911
911
label : label argument to provide to plot
912
912
kind : {'line', 'bar', 'hist'}
913
913
Default: line for TimeSeries, hist for Series
914
+ auto_x : if True, it will use range(len(self)) as x-axis
914
915
kwds : other plotting keyword arguments
915
916
916
917
Notes
@@ -929,25 +930,52 @@ def plot(self, label=None, kind='line', rot=30, axes=None, style='-',
929
930
930
931
N = len (self )
931
932
932
- if axes is None :
933
- axes = plt .gca ()
933
+ if ax is None :
934
+ ax = plt .gca ()
934
935
935
936
if kind == 'line' :
936
- axes .plot (self .index , self .values , style , ** kwds )
937
+ if use_index :
938
+ x = self .index
939
+ else :
940
+ x = range (len (self ))
941
+
942
+ ax .plot (x , self .values , style , ** kwds )
937
943
elif kind == 'bar' :
938
944
xinds = np .arange (N ) + 0.25
939
- axes .bar (xinds , self .values , 0.5 , bottom = np .zeros (N ), linewidth = 1 )
945
+ ax .bar (xinds , self .values , 0.5 , bottom = np .zeros (N ), linewidth = 1 )
940
946
941
947
if N < 10 :
942
948
fontsize = 12
943
949
else :
944
950
fontsize = 10
945
951
946
- axes .set_xticks (xinds + 0.25 )
947
- axes .set_xticklabels (self .index , rotation = rot , fontsize = fontsize )
952
+ ax .set_xticks (xinds + 0.25 )
953
+ ax .set_xticklabels (self .index , rotation = rot , fontsize = fontsize )
948
954
949
955
plt .draw_if_interactive ()
950
956
957
+ def hist (self , ax = None ): # pragma: no cover
958
+ """
959
+ Draw histogram of the input series using matplotlib / pylab.
960
+
961
+ Parameters
962
+ ----------
963
+
964
+ Notes
965
+ -----
966
+ See matplotlib documentation online for more on this subject
967
+
968
+ Default plot-types: TimeSeries (line), Series (bar)
969
+
970
+ Intended to be used in ipython -pylab mode
971
+ """
972
+ import matplotlib .pyplot as plt
973
+
974
+ if ax is None :
975
+ ax = plt .gca ()
976
+
977
+ ax .hist (self .values )
978
+
951
979
def toCSV (self , path ):
952
980
"""
953
981
Write the Series to a CSV file
0 commit comments