[Matrix-SIG] Python interface for PPGPLOT

Scott M. Ransom ransom@cfa.harvard.edu
Sun, 18 Oct 1998 04:36:41 +0000


Hello all,

As a first Python project, I decided to write Python wrappers
(Pgplot.py) around the 'PPGPLOT' CPython wrappers around the 'cpgplot' C
wrappers around the 'pgplot' Fortran library!  ;)

The reason for doing such a ludicrous sounding thing is to make high
quality 1D and 2D plotting as blatantly easy from Python as it is in
IDL, Matlab, etc...  And the end result is that it does (pretty much)
just that.

And besides, it was a good project to help me learn Python (which I am
now completely addicted to).

I have posted the file at the following URL:

ftp://cfa0.harvard.edu/pub/ransom/Pgplot.py

The code is well commented and includes string comment blocks describing
how each procedure is used.  The code can also be run straight from the
command line (i.e. 'python Pgplot.py') where it will demo a few of its
abilities.

Please feel free to use, modify, or ignore any or all of it as you see
fit.

I would definitely be interested in any feedback, bug reports, or
suggestions that you might have.

Scott Ransom

PS:  I am also interested in seeing if anyone can suggest a better way
of performing the following function (it is included in the demo code):

------------
import Numeric

def distance(width):
    """
    distance(width):
        Return a 'width' x 'width' Numeric Python array with each
            point set to the geometric distance from the array's center.

    """
    x = Numeric.arange(-width/2.0+0.5, width/2.0+0.5, 1.0)
    x = Numeric.resize(x, (width,width))
    return Numeric.sqrt(x**2 + Numeric.transpose(x)**2)
------------

--
Scott M. Ransom
Phone:  (580) 536-7215             Address:  703 SW Chaucer Cir.
email:  ransom@cfa.harvard.edu               Lawton, OK  73505
PGP Fingerprint: D2 0E D0 10 CD 95 06 DA  EF 78 FE 2B CB 3A D3 53