This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

PyChart is a Python library for creating high quality Encapsulated Postscript, PDF, PNG, or SVG charts. It currently supports line plots, bar plots, range-fill plots, and pie charts.

Here's a quick example of using PyChart in a CGI script to dynamically create and return a plot in PNG format. Just copy/paste the following code into a file (say, generate_plot.py), set permissions to 755, drop it into your cgi-bin directory, and point your browser at it. (Please see the official PyChart docs for plenty of nicely-commented examples.)

   1 #!/usr/bin/python
   2 
   3 import random
   4 import sys
   5 
   6 # Not using the cgi module at the moment.
   7 #import cgi
   8 #import cgitb; cgitb.enable()
   9 
  10 from pychart import *
  11 
  12 print "Content-type: image/png"
  13 print
  14 
  15 sys.argv.append( '--format=png' )
  16 
  17 theme.get_options()
  18 theme.scale_factor = 2
  19 theme.reinitialize()
  20 
  21 data = []
  22 for i in range(10):
  23     data.append( (i, random.random()* 3.0) )
  24 
  25 xaxis = axis.X( format="/hL%d",  label="time" )
  26 yaxis = axis.Y(  label="synaptic activity" )
  27 
  28 ar = area.T( x_axis=xaxis, y_axis=yaxis, y_range=(0,None), size=(120,110) )