#/usr/bin/env python
# coding:utf-8
import pg
import sys
import datetime
from pylab import *
def main():
argvs = sys.argv
argc = len(argvs)
""" check argument """
if (argc != 1 + 6):
argument = "dbname dbuser dbpass fromdate todate dbtable_prefix"
print "Usage: python %s %s" % (argvs[0], argument)
sys.exit(1)
dbname=argvs[1]
dbuser=argvs[2]
dbpass=argvs[3]
fromdate=argvs[4]
todate=argvs[5]
prefix=argvs[6]
""" initialization """
initGraphParams()
dbobj = getConnection(dbname, dbuser, dbpass)
""" get X label """
Lx = makeX(fromdate, todate)
Lx2 = makeX2(fromdate, todate)
""" get X,Y data """
classes = getClassId()
styles = ('-', 'x-', '+-', '*-')
colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k')
count = 0
for cls in classes:
Ly = makeY(dbobj, Lx, prefix, 'class', cls, 'rows')
style = styles[count % len(styles)]
color = colors[count % len(colors)]
plot(Lx2, Ly, style+color, label=cls)
count += 1
title('number of XXX')
xlabel('date')
ylabel('number')
grid(True)
legend(bbox_to_anchor=(1.01, 1), loc=2, ncol=2, borderaxespad=0.)
show()
dbobj.close()
2011/07/13
python tips: matplotlib plot option
ラベル:
python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment