Skip to content

Commit 623d5c1

Browse files
committed
bar chart option in Series.plot
git-svn-id: http://pandas.googlecode.com/svn/trunk@98 d5231056-7de3-11de-ac95-d976489f1ece
1 parent d55fec2 commit 623d5c1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

pandas/core/series.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,30 @@ def plot(self, label=None, kind='line', **kwds): # pragma: no cover
692692
----
693693
See matplotlib documentation online for more on this subject
694694
"""
695-
import pylab
695+
import matplotlib.pyplot as plt
696696

697697
if label is not None:
698698
kwds = kwds.copy()
699699
kwds['label'] = label
700700

701-
pylab.plot(self.index, self, **kwds)
701+
N = len(self)
702+
703+
if kind == 'line':
704+
plt.plot(self.index, self.values(), **kwds)
705+
706+
# ax = plt.gca()
707+
# ax.autoscale_view(scalex=True, scaley=True)
708+
709+
# locs, labels = plt.xticks()
710+
# new_locs = locs[::len(locs) // 8]
711+
# plt.xticks(new_locs, rotation=20)
712+
713+
elif kind == 'bar':
714+
xinds = np.arange(N) + 0.25
715+
plt.bar(xinds, self.values(), 0.5, bottom=np.zeros(N), linewidth=1)
716+
fontsize = 12 if N < 10 else 10
717+
718+
plt.xticks(xinds + 0.25, self.index, rotation=30, fontsize=fontsize)
702719

703720
def toCSV(self, path):
704721
"""

0 commit comments

Comments
 (0)