Bill Casselman's home page

PiScript - a drawing tool for mathematicians

PiScript is a package written by Bill Casselman in the programming language Python that interfaces in a straightforward way to PostScript graphics commands. It is designed for use by those who are interested in producing graphics in mathematical exposition. Its principal features are the directness of the interface and the ease with which one can insert TEX text into figures.

New (as of July 21) is that PiScript now seems to work on Windows machines. Thanks to Christophe K. and Yair Goldberg for help. Read the Manual for more remarks about this.

Downloads and installation

Documentation

  • The manual for PiScript in .pdf and also in .ps format.

    The .pdf file produced by .epstopdf is not quite accurate. Compare the two versions of the middle diagram on p.13. The official Acrobat from Adobe does better.

  • My own notes on Type 1 fonts (.pdf)

    I have spent a lot of time exploring fonts for this project, although this work has barely shown up so far in PiScript.

  • PiScript command list

Examples

You will see the Python file that produced an image if you click on it (assuming your browser is set to load .py files as text files, which it should do for security reasons). If you have installed a tool to view .eps files, you may also click on the file names beneath the image.

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps

.eps
The following are multi-page displays:

.eps

.eps

.eps

.eps

.eps

Major source code

  • PiModule.py. This is the basic interface to the classes in the files below. No serious work is done here.
  • PiScript.py. The basic code, including the class PiScript.
  • PiScript3d.py. The 3D code, including classes ConvexSurface, Face, PiScript3d
  • Cube.py - a sample polyhedron
  • Sphere.py - a sample smooth surface

Other links

Other graphics packages for mathematicians

  • Among all the packages mentioned here, this is closest to PiScript. It handles TEX text in a similar fashion, but does not follow the PostScript graphics model very closely.

  • PyScript

    Similar in spirit as well as homonymous, but not a finished product (and it is not clear to me that it is still an active project, either). Like PYX, it does not follow PostScript as closely as I would like, but it does have interesting TEX text placement.

  • Matplotlib (which is used in SAGE)

    This models itself on MatLab. Very powerful for big data plotting tasks.

  • The Processing project.

    More art than mathematics, but the images its enthusiastic users produce are often really beautiful.

  • IPE

    By some of the authors of the book Computational Geometry, now in a third edition. The book is one of the few about algorithms in computer graphics that displays competent pictures. If the illustrations in the book were written with IPE, that's a good advertisement.

  • VRR

    Like IPE, this is an interactive graphics tool, rather than a programming tool. My impression is that neither of them is useful for mathematicians with little programming experience.

  • Xfig

    A standard tool, used by multitudes. Ugly, ugly, ugly. But interactive. Not to say, well prepared.

  • PSTricks

    This is one of several packages that make pictures in a LaTeX environment, rather than TeX/LaTeX in a graphics environment, which I find by far preferable. It is in effect a LaTeX interface to PostScript, and for that reason rather awkward as well as limited. PostScript is a rather interesting, even elegant, programming language, but LaTeX ... ? (However, see the next item.) I find it curious that many graphics tools for mathematicians often assume that the user does not want to do any real programming. Mathematicians are notoriously conservative about computers, so maybe they have a point.

  • PGF & TikZ. See also Kjell Fauske's home page.

    These too are based on a LaTeX environment, but they do much, much better than any others in this category. For example, there is a 3D package using Gene Ressler's Sketch, which has many interesting features, particularly the transparency effects.

  • gnuplot

    Very limited.

  • Xy-pic

    The favourite of many for setting commutative diagrams, which it does well. Like two above, this is based on TeX.

  • VfPlot

    Seems designed just to plot vector fields. But it does this in a very sophisticated way.

  • PythonPS

    Another Python interface to PostScript programming from the guy who brought you the PostScript web server PSD-HTTPD. Very spare.

  • MetaPost

    An interface to PostScript in Don Knuth's graphics language MetaFont, which he designed and used to make the Computer Modern fonts that come with TEX. By John Hobby, a former student of Knuth's. Much if not all of Knuth's own graphics is done with this tool (as you can see from Knuth's preprints page, particularly the color figures for dancing links), and it is therefore not to be scorned. To my eye, however, the figures it produces have a rather monotonous style, which indicates that variety, although possible in principle, is not easy to achieve. See also the Wikipedia entry on MetaPost.

  • Asymptote

    From the home page: ... inspired by MetaPost, with a much cleaner, powerful C++-like programming syntax and floating-point numerics. It seems surprisingly powerful. Among other features, it has an interesting and sophisticated approach to keeping certain parts of a figure at a fixed size while scaling the rest (which PiScript handles with revert).

NOTE: I welcome comments on any of these tools (mail to cass at math.ubc.ca). It would be extremely useful even to assemble a table comparing features such as
  • TEX and text handling
  • programming convenience
  • coordinate changes
  • library quality
  • 3D capability
  • control of graphics details
  • speed of rendering
  • ease of expansion
and whatever else distinguishes a good graphics program. It should include elementary samples of coding. But this is not a job for just one person.