Looking for a pure Python chart drawing module

J

John Nagle

I'm looking for something that can draw simple bar and pie charts
in Python. I'm trying to find a Python package, 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 the Python wiki 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 from http://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.
* Gnuplot module -- 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 - python wrapper 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, but last updated 21-Dec-2005.
* PyNGL - uses PyNIO, which is in C
* pygooglechart - Python interface to the Google Chart LookinAPI, only works in
browser

So, for pure Python, Pychart is it. I'll have to try it and see if it still
works.

John Nagle
 
V

Vlastimil Brom

2009/9/15 John Nagle said:
I'm looking for something that can draw simple bar and pie charts
in Python.  I'm trying to find a Python package, 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 the Python wiki at
"http://wiki.python.org/moin/NumericAndScientific/Plotting".
Almost all the options are really wrappers for some other
package in C/C++.
...
* BLT - "tcltk.com" link goes to a domain squatter site.
...
So, for pure Python, Pychart is it.  I'll have to try it and see if it still
works.

                               John Nagle

As for BLT, there is Pmw.Blt, the original is written in Tcl.
http://sourceforge.net/projects/blt/
http://pmw.sourceforge.net/doc/Blt.html
http://heim.ifi.uio.no/~hpl/Pmw.Blt/doc/

Maybe Tcl/Pmw has less problems on different platforms, but isn't pure
python either; moreover I'm not sure what graph types are supported.

vbr
 
I

ici

I'm looking for something that can draw simple bar and pie charts
in Python.  I'm trying to find a Python package, 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 the Python wiki 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.
* Gnuplot module -- 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 - python wrapper 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, but last updated 21-Dec-2005.
* PyNGL - uses PyNIO, which is in C
* pygooglechart - Python interface to the Google Chart LookinAPI, only works in
browser

So, for pure Python, Pychart is it.  I'll have to try it and see if it still
works.

                                John Nagle

My choice is PyQWT but few monts before I started pure python tkinter
cartesian plot control:
screenshot: http://www.iltchev.com/tkplot/tkplot.png
source: http://www.iltchev.com/tkplot/tkplot.py.txt

This class is in a very early stage, but I think it is good start. :)
 
J

John Nagle

John said:
I'm looking for something that can draw simple bar and pie charts
in Python. I'm trying to find a Python package, 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 the Python wiki 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 from http://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.
* Gnuplot module -- 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 - python wrapper 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 - Python interface to the Google Chart LookinAPI, only
works in browser

So, for pure Python, 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 any pure Python chart module at all.
Just wrappers.

John Nagle
 
E

Ethan Furman

John said:
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 any pure Python chart module at all.
Just wrappers.

John Nagle

http://home.gna.org/pychart/doc/module-theme.html

<excerpt>
output_format
This variable sets the encoding of the data produced by PyChart. The
value of this variable must be one of the following strings.

ps:
eps:
Encapsulated PostScript. This is the default.

pdf:
Adobe Page Description Format, or PDF.

pdf-uncompressed:
PDF without compression. This option should be used for a debugging
purpose only.

png:
PNG graphics. You need to have ghostscript (gs) installed to use this
option, because PyChart internally calls ghostscript to convert
PostScript to PNG.
</excerpt>

Looks like it will directly create pdf files, not sure if that will for you.

Hope this helps.

~Ethan~
 
G

gerlos

John Nagle ha scritto:
I'm looking for something that can draw simple bar and pie charts
in Python. I'm trying to find a Python package, not a wrapper for
some C library, as this has to run on both Windows and Linux
and version clashes are a problem.

Did you look at matplotlib? In their examples page there are some charts
like the ones you asked for. I guess it could work for you, and it seems to
work flawlessy in MS Windows as in gnu/linux.

regards
gerlos
 
J

John Nagle

gerlos said:
John Nagle ha scritto:


Did you look at matplotlib? In their examples page there are some charts
like the ones you asked for. I guess it could work for you, and it seems to
work flawlessy in MS Windows as in gnu/linux.

That's a wrapper for Antigrain ("http://www.antigrain.com/"), which is
a C++ library. I'm trying hard to avoid dependencies on binary libraries
with limited support. Builds exist only for Python 2.4 and 2.5.

John Nagle
 
J

John Nagle

Alan said:
There's John Zelle's graphics.py:
http://mcsp.wartburg.edu/zelle/python/
provides basic functionality.

"The package is a wrapper around Tkinter". It runs Tkinter
in a separate thread and sends commands to it.

That's a wrapper for the BLT package for Tcl.
(http://blt.sourceforge.net/). The documentation
for the wrapper says it was developed for Windows 98.
pygooglechart
You suggested this needs a browser, but not so,
you can download the PNGs and use the default viewer
to display them.

That outsources the job to Google, which could choose at any time
to cancel that service (as they did, for example, with their SOAP-based
search API.)

"You acknowledge and agree that Google may stop (permanently or
temporarily) providing the Services (or any features within the Services) to you
or to users generally at Google’s sole discretion, without prior notice to you."

Besides, outsourcing something this basic just adds something else
that can break.

John Nagle
 
M

Michel Claveau - MVP

Hi!

Perso I use a wrapper to RMCHART.
There are two versions : DLL & COM. I prefer COM.
Warning : only on Windows's family.

@-salutations
 
A

Alan G Isaac

"The package is a wrapper around Tkinter". It runs Tkinter
in a separate thread and sends commands to it.


Tkinter is part of the Python standard library:
http://docs.python.org/library/tk.html
Are you really ruling out its use for a "pure Python"
solution?

If you want a Python solution to not just create
the graphs but also to view them, it is hard to
see how you will do without this. What exactly
are you trying to accomplish?

Alan Isaac

PS I think ReportLab can generate PDF vector graphics
even in the absence of a C compiler (which it will
use if available).
 
R

rober

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
 
R

Robin Becker

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!
We've been having some problems with Blt in various 64 bit versions of ubuntu. I
don't use it directly, but PMW does when it's available. I kept getting segfault
crashes opening up various dialogs. Googling eventually traced these to Blt.
Hacking the PMW code to make PMW run without BLT was fairly easy and did cure
the problem.
 
M

Michel Claveau - MVP

Hi!
Tkinter is part of the Python standard library

Yes.
But...
tkinter is a wrapper to tcl/tk, who is written in tcl. Ok, tcl is given with Python (standard library).
Therefore, you sentence:
'Are you really ruling out its use for a "pure Python" solution?'
Is well done...
;-)

Michel Claveau
 
J

John Nagle

PyChart generates SVG reasonably well, and needs no external programs
when generating SVG. But there's something
broken related to font sizes. Larger values of "font-size" produce
smaller type, and chart labels don't fit their boxes.
I'm trying to figure out whether PyChart is generating
incorrect SVG or whether Mozilla is incorrectly rendering SVG.

John Nagle
 
G

Giacomo Boffi

Vlastimil Brom said:
As for BLT, there is Pmw.Blt, the original is written in Tcl.

doesn't work (dumps core) on debian linux
bug #525860: python-pmw triggers segmentation fault in blt

not that blt itself is really OK
bug #524149: blt: zooming in a graph produces segmentation fault
 
G

Giacomo Boffi

John Nagle said:
That's a wrapper for Antigrain ("http://www.antigrain.com/"), which is
a C++ library.

come on, you can configure matplotlib to use one of too many different
backends

from http://matplotlib.sourceforge.net/users/customizing.html

#### CONFIGURATION BEGINS HERE

# the default backend; one of GTK GTKAgg GTKCairo CocoaAgg FltkAgg
# MacOSX QtAgg Qt4Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG Template
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
# 'module://my_backend'
backend : GTKAgg
 
C

Chris Colbert

by your definitions, Python is just a wrapper around a C library.

If none of the solutions work for you, roll your own.
 
C

Chris Withers

John said:
That's a wrapper for Antigrain ("http://www.antigrain.com/"), which is
a C++ library. I'm trying hard to avoid dependencies on binary libraries
with limited support. Builds exist only for Python 2.4 and 2.5.

Huh?

Matplotlib is a pretty phenomenal charting library, I use it routinely
on both windows and linux, I've never had any compilation problems on
Linux and never even needed to compile it on Windows.

Writing if off as "just a wrapper for antigrain" is pretty insulting...

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top