Batch/Interactive Operation

Gnuplot may be executed in either batch or interactive modes, and the two may even be mixed together on many systems.

Any command-line arguments are assumed to be either program options (see command-line-options) or names of files containing gnuplot commands. Each file or command string will be executed in the order specified. The special filename "-" is indicates that commands are to be read from stdin. Gnuplot exits after the last file is processed. If no load files and no command strings are specified, gnuplot accepts interactive input from stdin.

Command line options

Gnuplot accepts the following options on the command line
-V, --version
-h, --help
-p  --persist
-d  --default-settings
-s  --slow
-e  "command1; command2; ..."
-c  scriptfile ARG1 ARG2 ...

-p tells the program not to close any remaining interactive plot windows when the program exits.

-d tells the program not to execute any private or system initialization (see initialization).

-s tells the program to wait for slow font initialization on startup. Otherwise it prints an error and continues with bad font metrics.

-e "command" tells gnuplot to execute that single command before continuing.

-c is equivalent to -e "call scriptfile ARG1 ARG2 ...". See call.

Examples

To launch an interactive session:
gnuplot

To launch a batch session using two command files "input1" and "input2":

gnuplot input1 input2

To launch an interactive session after an initialization file "header" and followed by another command file "trailer":

gnuplot header - trailer

To give gnuplot commands directly in the command line, using the "-persist" option so that the plot remains on the screen afterwards:

gnuplot -persist -e "set title 'Sine curve'; plot sin(x)"

To set user-defined variables a and s prior to executing commands from a file:

gnuplot -e "a=2; s='file.png'" input.gpl

Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
Distributed under the gnuplot license (rights to distribute modified versions are withheld).