Scientific plotting with Pygist
Updated May 28, 2007; Pygist version 1.5.28
Gist is a scientific graphics library written by David H. Munro of Lawrence Livermore National Laboratory. It produces x-vs-y plots, 2-D quadrilateral mesh plots with contours, filled contours, vector fields, or pseudocolor maps on such meshes. Some 3-D plot capabilities are also available. PyGist is the corresponding extension module for Python. Until recently, PyGist was available for Linux/Unix machines only. Together with the good people at Livermore, we managed to port PyGist to Mac OS X, Windows, and Cygwin. For Mac OS X, there is both a native version of Pygist and an X11 version. For the latter, you need to install X11 for Mac OS X; the native version uses Quartz directly.
Below you will find an installer for Windows, as well as the source distribution that can be used for Cygwin and Mac OS X. The installer for Windows works with Python's with Python run from the DOS prompt.
For some screen shots, click here: sinus, histogram, cardioids, colors, cellarray, gist3d, sombrero. You can get a demonstration of the capabilities of Pygist by executing
>>> from gist import gistdemolow
>>> gistdemolow.run()
You can find more examples in gistdemo3d and gistdemomovie.
Some useful commands:
>>> from gist import * # to import the gist graphics package
>>> window() # to open the window where the plots will appear
>>> x = arange(100) * 0.1 # this uses the Numerical Python package
>>> y = sin(x)
>>> plg(y,x) # Now you should see a sine wave in the graphics window
# Note that y comes first (so that the x can be optional)
>>> fma() # frame advance to go to the next plot
>>> y = arange(10)
>>> plh(y) # to draw a histogram
Pygist allows you to make postscript files of the plots that you made:
>>> hcp_file('myplot.ps') # opens a postscript file called myplot.ps
>>> hcpon() # From now on, write the plot to the postscript file after each frame advance
>>> fma() # frame advance
>>> hcpoff() # Stop writing plots to the postscript file
Manual
Pygist has many more capabilities, check out the manual (HTML, PDF) if you want to know more.
Installation instructions:
- For Python run on Windows (using the command line, not IDLE), use the Windows installer:
The previous version is still available:
Also see the known bugs and issues.
- For Cygwin/Linux/Unix/Mac OS X, download the source distribution pygist-1.5.28.tar.gz (previous version pygist-1.5.24.tar.gz). Unpack the file with
gunzip pygist-1.5.28.tar.gz; tar -xvf pygist-1.5.28.tar. Change to the pygist-1.5.28 directory.
- If you are on a regular Unix/Linux machine and you are using Python 2.3 or newer, run
python setup.py config
python setup.py build
python setup.py install
For the last step, you may need superuser privileges. You can also install Pygist in your home directory using
python setup.py install --prefix=/your/home/directory
If you have an older version of Python, change to the pygist-1.5.28/src directory, and run
make config
Then change back to the pygist-1.5.28 directory, and run
python setup.py build
python setup.py install
- On Cygwin, if you want to use Pygist without relying on XFree86, run
python setup.py config
python setup.py build
python setup.py install
If you want to use Pygist with XFree86, run
python setup.py config --x11
python setup.py build --x11
python setup.py install --x11
If you are using a Python version older than 2.3, you may need to add an additional --compiler=cygwin flag.
- On Mac OS X, if you want to use Pygist natively (so without using X11), run
python setup.py config
python setup.py build
python setup.py install
Below you will find some more guidance on how to install Pygist natively on Mac OS X.
If you want to use Pygist on Mac OS X with X11, run
python setup.py config --x11
python setup.py build --x11
python setup.py install --x11
This version of pygist should work with Mac OS X 10.4 (Tiger) as well as older versions of Mac OS X. Thanks to Sébastien Maret of the University of Michigan for his contribution to pygist on Mac OS X 10.4.
Known bugs and issues:
- A mouse click in a graphics window lets you zoom in. If the graphics window is currently covered, for example by the command window, then the graphics window does not get repainted correctly if you click in it. Minimizing and restoring the graphics window solves this problem. The same bug appears in yorick's gist for windows, where python's gist came from.
- Pygist currently has a problem with Python on Microsoft Windows when using IDLE. This is due to some missing machinery to support event loops in Python; we don't expect this issue to be fixed soon.
Running Pygist natively on Mac OS X
The native version of Pygist on Mac OS X uses Quartz and can be run directly from a Terminal window. To use the native version, you first need to make sure that you are using a framework installation of Python, otherwise the Pygist graphics windows won't interact correctly with the Mac's windowing system. A framework Python can be installed by adding --enable-framework to the configure script that is run when installing Python from the source. With versions of Python older than 2.5, you should run pythonw instead of python for the graphics windows to work correctly. With Python 2.5 and later, this is not necessary; you can simply use python.
To install Pygist, you will also need Numerical Python of course.
Then, to install pygist, in the pygist-1.5.28 directory run
python setup.py config
python setup.py build
sudo python setup.py install
The first command will generate a lot of warnings and error messages.
These are due to failed trial compilations and can be ignored. If you
want to install the X11 version instead of the native Quartz version,
then you need to add --x11 to these commands.
I built the native version of Pygist using version 10.3 of Mac OS X. Pygist should run with older versions also, except that the crosshair cursor is not available (you will get the usual arrow instead). If you have a single-button mouse, you can use the control and option key to simulate the other mouse buttons.
License information:
See the release notes for license information and disclaimer.