creating graphs from lists

John Hunter jdhunter at ace.bsd.uchicago.edu
Wed Jun 30 07:56:05 EDT 2004


>>>>> "Luis" == Luis P Mendes <luis_ at iname.com> writes:

    Luis> I'm developing a program in Python, with no gui, and now
    Luis> I've reached a point where I would need to plot list of
    Luis> elements on a graph.

    Luis> How can I do it?  preferably in a simple way?


matplotlib has non GUI-outputs.  You select these by choosing your
"backend".  There are two ways of doing this, from the prompt or in a
configuration file.  Let's say you have a script to plot a list

  from matplotlib.matlab import *
  plot([1,2,3])
  savefig('somefile')

If you run this script as

  > python myscript.py -pPS    # generate postscript somefile.ps
  > python myscript.py -pSVG   # generate SVG somefile.svg
  > python myscript.py -pAGG   # generate somefile.png

If you know you always want to generate png for example, you can set
this by default and don't have to supply the command line option.

matplotlib also has a GUI mode, but you don't need it.

homepage    : http://matplotlib.sourceforge.net
screenshots : http://matplotlib.sourceforge.net/screenshots.html
tutorial    : http://matplotlib.sourceforge.net/tutorial.html

John Hunter





More information about the Python-list mailing list