hi, I'm having trouble figuring out how to add a few more
> layers to a stacked bar graph. What I have so far is:
> p1 = axes.bar(ind, data['n'], width, color='r') p2
> = axes.bar(ind, data['l'], width, color='y',
> bottom=data['n']) p3 = axes.bar(ind, data['m'], width,
> color='b', bottom=data['l']) p4 = axes.bar(ind, data['h'],
> width, color='g', bottom=data['m'])
> But I don't think this is correct. I only get two layers
> (red and green). Does anyone know the proper method?
See examples/table_demo.py -- you need to keep a cumulative sum of the
bottom positions, eg
yoff = array([0.0] * len(colLabels)) # the bottom values for stacked bar chart
for row in xrange(rows):
bar(ind, data[row], width, bottom=yoff, color=colours[row])
yoff = yoff + data[row]
cellText.append(['%1.1f' % (x/1000.0) for x in yoff])
JDH