Scripting gnuplot with its own language
We have learned how to use a large number of gnuplot commands and assembled them into scripts, included with this book as code samples, that can be executed from the command line or read in from the gnuplot's interactive plot with the load
command. Up to now, however, these scripts have taken the form of a simple sequence of commands, each one to be executed once; the same result is obtained whether we enter the commands one at a time at the prompt or load the script as a whole, in batch mode.
There are many tasks that are much more convenient, and others that are only possible, if we can apply some sort of automation to the generation of commands. Fortunately, gnuplot, as part of its command language, includes a simple facility for applying some basic programming constructs. There is a basic looping control, a way to iterate over a set of commands, and an if—then—else
statement. With these few borrowings from procedural languages, we can do a great...