1.1 Overview

PyXPlot is a stand-alone command-line graphing package that is simple to use yet produces high-quality attractive output suitable for use in publications. For ease of use, its interface is based heavily upon that of the popular Gnuplot plotting package, so users do not need to learn a whole new scripting language. However, it uses the PyX graphics library to produce its output, allowing the quality of its output to reach modern standards. The command-line interface has also been extended by addition of tools to carry out some commonly-required data-processing. An attempt has been made to rectify frequently-noted flaws in Gnuplot; for example, all text is now rendered automatically in the LaTeX typesetting environment, making it straightforward to label graphs with mathematical expressions. The multiplot environment has been re-designed from scratch, making it easy to produce galleries of plots with basic vector graphics around them. For some samples of the results of which PyXPlot is capable, the reader is referred to the project website1.

The ability to represent data visually, usually as some form of graph, is a requirement for any scientific or mathematical work. Historically, a very widely-used open-source plotting programme has been Gnuplot, the principal attraction of which is its easy-to-use command-line interface, which allows data files to be turned into graphs within seconds. One of its main rivals has been Pgplot, which is somewhat more flexible, but much less easy to use; it can only be called from within a programme, and so code must be written to produce each plot. This is potentially time consuming, and it is necessary for the user to have some programming experience.

Alongside these, several commercial packages have existed, including Maple, Mathematica and SuperMongo. These can typically produce prettier results than their free counterparts, but carry with them considerable price tags and licensing restrictions. Moreover, none of these are as easy to use as Gnuplot.

Both Gnuplot and Pgplot were developed in the mid-1980s. At that time, the quality of their output seemed state-of-the-art. But this is less true today. In most journal articles today, the text and equations are rendered with a high degree of professionalism by the LaTeX typesetting system. But all too often, the graphs are less neat. The same is often true of the slides used in presentations: graphs are often rendered with less professionalism than the text around them.

In the early 2000s, several new free graphing packages emerged, among them MatPlotLib and PyX. These have significantly improved upon the quality of the plots produced by Gnuplot and Pgplot. However, both are libraries which can be called from within the Python programming language, rather than stand-alone plotting packages. They are not as easy to use as Gnuplot. For visualising data at speed, Gnuplot remains the best option.

The command-line interface of Gnuplot is very flexible: it can be controlled interactively, by typing commands into a terminal, it can read a list of commands in from a file, or it can receive commands through a UNIX pipe from another process. These modes of use are all possible in PyXPlot too.

We argue that Gnuplot’s interface brings another distinct advantage to PyXPlot in comparison with plotting packages which insist upon being called from within a programming language. PyXPlot requires that data be written to a file on disk before it can be plotted. When plotting is done from within a programming language, this can tempt the user into writing programmes which both perform calculations and plot the results immediately. This sounds neat, but it can be a dangerous temptation. Remembering to store a copy of the data used to produce a graph becomes a secondary priority. Months later, when the need arises to replot the same data in a different form, or to compare it with newer data, remembering how to use a hurriedly written programme can prove tricky – especially if the programme was originally written by someone else. But a simple data file is quite straightforward to plot.

The similarity of PyXPlot’s interface to that of Gnuplot is such that simple scripts written for Gnuplot should work with PyXPlot with minimal modification; Gnuplot users should be able to get started very quickly. However, PyXPlot is still a work in progress, and a small number of Gnuplot’s features are still missing. A detailed list of which features are supported can be found in Section 2.14. The new features which have been added to the interface are described in Chapters 3 – 6.

A brief overview of Gnuplot’s interface is provided for novice users in Chapter 2. Past Gnuplot users may skip over this chapter, though their attention is drawn to one of the key changes to the interface – namely that all textual labels on plots are now rendered using the LaTeX typesetting environment. This does unfortunately introduce some incompatibility with Gnuplot, since some strings which were valid before are no longer valid (see Section 2.4 for more details). For example:

\includegraphics{cross}

set xlabel ’x\^{}2’

would have been valid in Gnuplot, but now needs to be written in LaTeX mathmode as:

\includegraphics{tick}

set xlabel ’$x\^{}2$’

The nuisance of this incompatibility is surely far outweighed by the power that LaTeX brings, however. For users with no prior knowledge of LaTeX we recommend Tobias Oetiker’s excellent introduction, The Not So Short Guide to LaTeX$2\epsilon $2.

Footnotes

  1. http://www.pyxplot.org.uk/
  2. Download from:
    http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf