Hi, I am trying to use the simple test.py program to draw a stacked bar graph. My intention is eventually to shrink this into a sparkline.
Both the sample program and the image output are attached. What I cannot understand is why the vertical bars don't align to the y-axis 0 point. Any help is appreciated. -shishir
import matplotlib
from pylab import *
table = {
'2007-07-30' : [0, 0, 0],
'2007-08-06' : [8, 3, 0],
'2007-08-13' : [12, 1, 7],
'2007-08-20' : [13, 13, 6] ,
'2007-08-27' : [11, 8, 11],
'2007-09-03' : [7, 6, 16],
'2007-09-10' : [8, 3, 20],
'2007-09-17' : [5, 3, 25],
}
colors = ['red', 'green', '#CFCFCF']
vals = table.keys()
vals.sort()
for i,interval in enumerate(vals):
print "%s : %s : %d " % (str(interval) , table[interval], i)
# opened
if table[interval][0] > 0 :
print "open: %d %d %d %d" % (i, i, 0, table[interval][0])
plot((i, i), (0, table[interval][0]),
color=colors[0], linewidth=3.0,aa=False)
# closed
if table[interval][1] > 0 :
print "closed: %d %d %d %d" % (i, i, 0, -table[interval][1])
plot((i, i), (0, -table[interval][1]),
color=colors[1], linewidth=3.0,aa=False)
# carry_over
if table[interval][2] > 0 :
print "carry: %d %d %d %d" % (i, i, table[interval][0], table[interval][2])
plot((i, i), (table[interval][0], table[interval][2]),
color=colors[2], linewidth=3.0, aa=False)
text(i, 0, str(i), size=4)
#plot((-1,i+1),(1,1), color='gray', linewidth=0.25)
plot((-1,i+1),(0,0), color='gray', linewidth=0.1)
savefig('c:/temp/test.png')
<<attachment: test.png>>
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
