5.2 Reading Data from a Pipe

PyXPlot usually reads data from files, but it is also possible to read data from pipes from other processes if these are directed to PyXPlot’s standard input stream. To do this, one uses the magic filename -:

plot '-' with lines

This makes it possible to call PyXPlot from within another program and pass it data to plot without ever storing the data on disk. Whilst this facility has great power, the authors would urge caution in this practice. Whilst it is tempting to write programs which both perform calculations and plot the results immediately, this can make it difficult to replot graphs later. A few months after the event, when the need arises to replot the same data in a different form or in a different style, remembering how to use a sizable program can prove tricky – especially if the person struggling to do so is not you! But a simple datafile is quite straightforward to plot time and again.