5.2 Reading data from a pipe

Pyxplot usually reads data from files, or samples it from functions. However, it is also possible to read data piped into it from other processes if these are directed to Pyxplot’s standard input stream, stdin. To do this, the magic filename - is used:

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, it should be used with caution.

It is often very tempting to write programs which both perform calculations and plot the results immediately, but 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 data file is quite straightforward to plot time and again.