Matplotlib is the preferred 2D plotting library for Python users. The following is a collection of very simple programs from Matplotlib's examples directory.

For more examples you may want to check out the Matplotlib Cookbook and the official matplotlib tutorial at http://matplotlib.sf.net/tutorial.html

Simple plot



#!/usr/bin/env python
"""
Example: simple line plot.
Show how to make and save a simple line plot with labels, title and grid
"""
import numpy
import pylab

t = numpy.arange(0.0, 1.0+0.01, 0.01)
s = numpy.cos(2*2*numpy.pi*t)
pylab.plot(t, s)

pylab.xlabel('time (s)')
pylab.ylabel('voltage (mV)')
pylab.title('About as simple as it gets, folks')
pylab.grid(True)
pylab.savefig('simple_plot')

pylab.show()



    7           9