Personal tools
You are here: Home Members rea SLUG Talks PyChart
Document Actions

PyChart

by Robert Anderson last modified 2007-05-14 20:47

The outline of the May 2007 talk

PyChart

homepage "http://home.gna.org/pychart"

Fedora Core

yum install pychart pychart-doc

examples

Website Examples "http://home.gna.org/pychart/examples/index.html"

command line examples

example using sqlite and my gas milage:

#!/usr/bin/python

 from pychart import *
 import sys
 import datetime
 import simpleDB

 def date_to_ordinal(s):
     year, month, day = map(int, s[:10].split("-"))
     return datetime.date(year, month, day).toordinal()

 def format_date(ordinal):
     d = datetime.date.fromordinal(int(ordinal))
     return "/a60{}" + d.strftime("%b %d, %y")

 def getMPGdata(dbfile):
     db = simpleDB.db(dbfile)

     cur = db.con.cursor()
     cur.execute('''select dtm, trip/quantity from gas_log order by dtm''')

     dat = []
     while True:
         r = cur.fetchone()
         if r is None: break
         dat.append(r)
     return dat

 # theme.use_color = 1
 theme.output_format = 'png'
 theme.reinitialize()

 theme.get_options()

 data = getMPGdata(sys.argv[1])
 data = chart_data.transform(lambda x: [date_to_ordinal(x[0]), x[1]], data)

 can = canvas.default_canvas()
 size = (800, 600)
 ar = area.T(size = size, legend=None, 
             x_axis = axis.X(format=format_date, label="Date"),
             y_axis = axis.Y(format="%0.1f", label="MPG"))
 ar.add_plot(line_plot.T(data=data))

 ar.draw()

cgi

Python CGI Tutorial "http://www.cs.virginia.edu/~lab2q"

ERROR: .python-eggs "http://forum.webfaction.com/viewtopic.php?pid=2152"

code:

import os 
os.environ['PYTHON_EGG_CACHE'] = '/tmp/apache.python_egg_cache'

Python documentation "http://www.python.org/doc/index.html"

Plone


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: