Chapter 12. Macros, scripting, and batch operations
This chapter covers
In the preceding 11 chapters, we’ve studied almost every command or option that can be used from within gnuplot. But up to this point, our discussions always assumed that we’d be running gnuplot interactively: actually entering commands at the gnuplot prompt, viewing the plot on the screen, and then entering more commands.
But sometimes that’s not what we want. For instance, we may have a large number of data sets and just want to convert all of them to plots using the same plot command. Or we may have a cron job running nightly to scan web server logs and want it to also generate some plots showing the number of hits per hour. Or we might want to use gnuplot as a graphing engine from within some other program, possibly even a web script.
In all these situations, we want to run gnuplot in the background, without human intervention. In this chapter, we study ways to do this, and also look at other things we can do with gnuplot that aren’t primarily interactive: macros, configuration, and the ability to interact with other programs.
The string-handling capabilities that gnuplot acquired in release 4.2 make it possible to construct command lines programmatically in a number of ways.