Looking for a pure Python chart drawing module

rober rfg007 at gmail.com
Wed Sep 16 16:02:06 CEST 2009


On Sep 15, 6:28 pm, John Nagle <na... at animats.com> wrote:
> John Nagle wrote:
> > I'mlookingfor something that can draw simple bar and pie charts
> > inPython.  I'm trying to find aPythonpackage, not a wrapper for
> > some C library, as this has to run on both Windows and Linux
> > and version clashes are a problem.
>
> > Here's the list from thePythonwiki at
> > "http://wiki.python.org/moin/NumericAndScientific/Plotting".
> > Almost all the options are really wrappers for some other
> > package in C/C++.
>
> > * Matplotlib -- wrapper for Antigrain, written in C/C++
> > * Veusz -- requires PyQt fromhttp://www.riverbankcomputing.co.uk/pyqt,
> > which is in C/C++
> > * Chaco -- requires binaries for Enthought Tool Suite
> > * ScientificPython - uses mix of C, C++, and FORTRAN.
> > * Gnuplotmodule-- wrapper for GNUPLOT
> > * plot_wrap - wrapper for GNU plotutils
> > * BLT - "tcltk.com" link goes to a domain squatter site.
> > * PyQT - wrapper for Qwt C++ library
> > * DISLIN - interface to C++ DISLIN system
> > * Mayavi - interface to Mayavai2, standalone program
> > * gdmodule GD -pythonwrapper for the GD library.
> > * Gist - wrapper for gist graphics library
> > * pgplot - Wrapper for pgplot.
> > * Py-OpenDX - wrapper for IBM Data Explorer
> > * VTK - wrapper for VTK in C++
> > * RPy - wrapper for R programming lnaguage
> > * PyX - wrapper for Tex.
> > * Biggles - wrapper for C++module
> > * Pychart - 100%Python (NOT!), but last updated 21-Dec-2005.
> > * PyNGL - uses PyNIO, which is in C
> > * pygooglechart -Pythoninterface to the GoogleChartLookinAPI, only
> > works in browser
>
> > So, forpurePython, Pychart is it.  I'll have to try it and see if it
> > still works.
>
> http://home.gna.org/pychart/doc/introduction.html
>
>     Tried PyChart.  Set up for PNG file format.  Got the error
> "Exception: Ghostscript not found."    This thing just creates
> PostScript, then pumps it through GhostScript (anybody remember that?)
> to get other formats. And does the documentation say that?  Only
> in the FAQ section.  Grrr.
>
>     There doesn't seem to be anypurePythonchartmoduleat all.
> Just wrappers.
>
>                                 John Nagle

Hi John,
I had the same problem using Btl. Blt generate postscript file and I
needed several others formats, then I did something like this:

....
cmd = [gspath,
       '-sDEVICE=%s'%device,
       '-sOutputFile=%s'%onormfile,
       '-dNOPAUSE -q -dBATCH',
       '%s'%inormfile,
      ]
gscmd = ' '.join(cmd)
try:
    retcode = call(gscmd, shell=True)
    if retcode > 0:
       log.error("'ghostscript' return whit error code '%d'"%retcode)
    except OSError, e:
       log.error("Error trying execute 'ghostscript'")
...

remarks:
- gspath is the absolute path to the ghostscript executable
- device can be 'pdfwrite', 'jpeg', 'bmp256', 'png256'
- onormfile is the output filename normalized to the OS
- inormfile is the postscript filename normalized to the OS
- call is the function of subprocess module

warning: ghostscript do not accept spaces in the filenames, so be
carefull if you is working in win32, even enclosing between " ".

PS:
For those people that sugest use Blt. I use Blt a lot in linux and
win32 but it is not port (yet) to TK8.5 so, it do not works with
py2.6, and is really painfull to build in win32.
Beside that, in order to use Blt, you need an instance of Tk running,
ergo a XWindows running, an some times it is not the case for linux
servers. In that cases I am using Mathplotlib, but a pure python
solution will be GREAT!

my 0.005 cents.

roberto






More information about the Python-list mailing list