I have a Pandas data Series which I want to plot based on months like this one :

Here is the code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import text file which holds ImageStack's path
df = pd.read_csv('file.txt', header=None)
df.columns = ['paths']
# Columns 2=Year, 3=Month, 4=Day
df = df.ix[:, 1:4].astype(int)
df.columns = ['year', 'month', 'day']
count = df.groupby(['year', 'month']).count()
count.columns = ['count']
months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
nmonths = len(months)
fig, ax = plt.subplots()
ind = np.arange(nmonths)
width = 0.45
nyears = len(count.index.levels[0])
p = []
for year in count.index.levels[0]:
df_empty = pd.DataFrame({'months': ind})
monthly_sum = df_empty.join(count.ix[year, :].groupby(level=0)
.sum())['count'].values
counts_until = df_empty.join(count.ix[:year, :].groupby(level=1)
.sum())['count'].values
p.append(ax.bar(ind, monthly_sum, width,
bottom=counts_until, alpha=0.8))
# Set x axis ticks and labels
ax.set_xticks(ind + width/2)
ax.set_xticklabels([months[i] for i in ind])
# Locate legend outside axes plot area
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend([pl[0] for pl in p], count.index.levels[0], loc='center left',
bbox_to_anchor=(1, 0.5))
plt.show()
DATA
year month day
0 2007 5 6
1 2007 5 6
2 2007 5 8
3 2007 5 8
4 2007 5 12
5 2007 5 15
6 2007 5 16
7 2007 5 19
8 2007 5 21
9 2007 5 21
10 2007 5 21
11 2007 5 24
But it does not give me a right Stacked bar chart ! I think the problem could be from counts_until is there someone can find a way to solve this problem !?

does not give me a right Stacked bar chart... what does it give you, and why is it wrong?