|
From: John H. <jdh...@ac...> - 2006-02-21 19:46:21
|
>>>>> "Jason" == Jason C Leach <jas...@gm...> writes:
Jason> hi, I'm having trouble figuring out how to add a few more
Jason> layers to a stacked bar graph. What I have so far is:
Jason> p1 = axes.bar(ind, data['n'], width, color='r') p2
Jason> = axes.bar(ind, data['l'], width, color='y',
Jason> bottom=data['n']) p3 = axes.bar(ind, data['m'], width,
Jason> color='b', bottom=data['l']) p4 = axes.bar(ind, data['h'],
Jason> width, color='g', bottom=data['m'])
Jason> But I don't think this is correct. I only get two layers
Jason> (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
|