1 gnuplot
?
GNUPLOT is a command-driven interactive function plotting program. It
is case sensitive (commands and function names written in lowercase
are not the same as those written in CAPS). All command names may be
abbreviated, as long as the abbreviation is not ambiguous. Any number
of commands may appear on a line, separated by semicolons (;).
Any command-line arguments are assumed to be names of files containing
gnuplot commands, with the exception of standard X11 arguments, which
are processed first. Each file is loaded with the `load` command, in the
order specified. Gnuplot exits after the last file is processed.
Commands may extend over several input lines, by ending each line but
the last with a backslash (\). The backslash must be the LAST
character on each line. The effect is as if the backslash and newline
were not there. That is, no white space is implied, nor is a comment
terminated. Therefore, commenting out a continued line comments out
the entire command (see `comment`).
In this documentation, curly braces ({}) denote optional arguments to
many commands.
For help on any topic, type 'help' followed by the name of the topic.
2 cd
?cd
The `cd` command changes working directory.
Syntax:
cd
The directory name must be enclosed in quotes.
Examples:
cd 'subdir'
cd ".."
2 clear
?clear
The `clear` command erases the current screen or output device as
specified by `set output`. This usually generates a formfeed on
hardcopy devices. Use `set terminal` to set the device type.
2 comment
?comments
Comments are supported as follows: a # may appear in most places in a line
and GNUPLOT will ignore the rest of the line. It will not have this
effect inside quotes, inside numbers (including complex numbers), inside
command substitutions, etc. In short, it works anywhere it makes sense
to work.
2 environment
?environment
A number of shell environment variables are understood by GNUPLOT.
None of these are required, but may be useful.
If GNUTERM is defined, it is used as the name of the terminal type to
be used. This overrides any terminal type sensed by GNUPLOT on start
up, but is itself overridden by the .gnuplot (or equivalent) start-up
file (see help start-up), and of course by later explicit changes.
On Unix and MS-DOS, GNUHELP may be defined to be the pathname of the
HELP file (gnuplot.gih).
On VMS, the symbol GNUPLOT$HELP should be defined as the name of
the help library for gnuplot.
On Unix, HOME is used as the name of a directory to search for
a .gnuplot file if none is found in the current directory.
On MS-DOS, GNUPLOT is used. On VMS, SYS$LOGIN: is used.
See help start-up.
On Unix, PAGER is used as an output filter for help messages. SHELL
is used for the `shell` command.
On MS-DOS, COMSPEC is used for the `shell` command.
2 exit
?exit
?quit
The commands `exit` and `quit` and your computer's END-OF-FILE character
will exit GNUPLOT. All these commands will clear the output device
(as the `clear` command does) before exiting.
2 expressions
?expressions
In general, any mathematical expression accepted by C, FORTRAN,
Pascal, or BASIC is valid. The precedence of these operators is
determined by the specifications of the C programming language.
White space (spaces and tabs) is ignored inside expressions.
Complex constants may be expressed as the {,}, where
and must be numerical constants. For example {3,2}
represents 3 + 2i; {0,1} represents `i` itself. The curly braces
are explicitly required here.
3 functions
?expressions functions
?functions
The functions in GNUPLOT are the same as the corresponding functions
in the UNIX math library, except that all functions accept integer,
real, and complex arguments, unless otherwise noted. The `sgn`
function is also supported, as in BASIC.
@start table
#Function & Arguments & Returns \\ \hline
%Function@Arguments@Returns
%_
4 abs
?expressions functions abs
?functions abs
?abs
#abs(x) & any & absolute value of {\tt x}, $|x|$; same type \\
#abs(x) & complex & length of {\tt x}, $\sqrt{{\mbox{real}(x)^{2} +
#\mbox{imag}(x)^{2}}}$ \\
%abs(x)@any@absolute value of x, $|x|$; same type
%abs(x)@complex@length of x, $sqrt{real (x) sup 2 + imag (x) sup 2}$
The `abs` function returns the absolute value of its argument. The
returned value is of the same type as the argument.
For complex arguments, abs(x) is defined as the length of x in the
complex plane [i.e., sqrt(real(x)**2 + imag(x)**2) ].
4 acos
?expressions functions acos
?functions acos
?acos
#acos(x) & any & $\cos^{-1} x$ (inverse cosine) in radians \\
%acos(x)@any@$cos sup -1 x$ (inverse cosine) in radians
The `acos` function returns the arc cosine (inverse cosine) of its
argument. `acos` returns its argument in radians.
4 arg
?expressions functions arg
?functions arg
?arg
#arg(x) & complex & the phase of $x$ in radians\\
%arg(x)@complex@the phase of $x$ in radians
The `arg` function returns the phase of a complex number, in radians.
4 asin
?expressions functions asin
?functions asin
?asin
#asin(x) & any & $\sin^{-1} x$ (inverse sin) in radians \\
%asin(x)@any@$sin sup -1 x$ (inverse sin) in radians
The `asin` function returns the arc sin (inverse sin) of its argument.
`asin` returns its argument in radians.
4 atan
?expressions functions atan
?functions atan
?atan
#atan(x) & any & $\tan^{-1} x$ (inverse tangent) in radians \\
%atan(x)@any@$tan sup -1 x$ (inverse tangent) in radians
The `atan` function returns the arc tangent (inverse tangent) of its
argument. `atan` returns its argument in radians.
4 besj0
?expressions functions besj0
?functions besj0
?besj0
#besj0(x) & radians & $j_{0}$ Bessel function of $x$ \\
%besj0(x)@radians@$j sub 0$ Bessel function of $x$
The `besj0` function returns the j0th Bessel function of its argument.
`besj0` expects its argument to be in radians.
4 besj1
?expressions functions besj1
?functions besj1
?besj1
#besj1(x) & radians & $j_{1}$ Bessel function of $x$ \\
%besj1(x)@radians@$j sub 1$ Bessel function of $x$
The `besj1` function returns the j1st Bessel function of its argument.
`besj1` expects its argument to be in radians.
4 besy0
?expressions functions besy0
?functions besy0
?besy0
#besy0(x) & radians & $y_{0}$ Bessel function of $x$ \\
%besy0(x)@radians@$y sub 0$ Bessel function of $x$
The `besy0` function returns the y0th Bessel function of its argument.
`besy0` expects its argument to be in radians.
4 besy1
?expressions functions besy1
?functions besy1
?besy1
#besy1(x) & radians & $y_{1}$ Bessel function of $x$ \\
%besy1(x)@radians@$y sub 1$ Bessel function of $x$
The `besy1` function returns the y1st Bessel function of its argument.
`besy1` expects its argument to be in radians.
4 ceil
?expressions functions ceil
?functions ceil
?ceil
#ceil(x) & any & $\lceil x \rceil$, smallest integer not less than $x$
#(real part) \\
%ceil(x)@any@$left ceiling x right ceiling$, smallest integer not less than $x$ (real part)
The `ceil` function returns the smallest integer that is not less than its
argument. For complex numbers, `ceil` returns the smallest integer
not less than the real part of its argument.
4 cos
?expressions functions cos
?functions cos
?cos
#cos(x) & radians & $\cos x$, cosine of $x$ \\
%cos(x)@radians@$cos~x,$ cosine of $x$
The `cos` function returns the cosine of its argument. `cos` expects its
argument to be in radians.
4 cosh
?expressions functions cosh
?functions cosh
?cosh
#cosh(x) & radians & $\cosh x$, hyperbolic cosine of $x$ \\
%cosh(x)@radians@$cosh~x,$ hyperbolic cosine of $x$
The `cosh` function returns the hyperbolic cosine of its argument.
`cosh` expects its argument to be in radians.
4 exp
?expressions functions exp
?functions exp
?exp
#exp(x) & any & $e^{x}$, exponential function of $x$ \\
%exp(x)@any@$e sup x$, exponential function of $x$
The `exp` function returns the exponential function of its argument
(`e` raised to the power of its argument).
4 floor
?expressions functions floor
?functions floor
?floor
#floor(x) & any & $\lfloor x \rfloor$, largest integer not greater
#than $x$ (real part) \\
%floor(x)@any@$left floor x right floor$, largest integer not greater than $x$ (real part)
The `floor` function returns the largest integer not greater than its
argument. For complex numbers, `floor` returns the largest
integer not greater than the real part of its argument.
4 imag
?expressions functions imag
?functions imag
?imag
#imag(x) & complex & imaginary part of $x$ as a real number \\
%imag(x)@complex@imaginary part of $x$ as a real number
The `imag` function returns the imaginary part of its argument as a
real number.
4 int
?expressions functions int
?functions int
?int
#int(x) & real & integer part of $x$, truncated toward zero \\
%int(x)@real@integer part of $x,$ truncated toward zero
The `int` function returns the integer part of its argument, truncated
toward zero.
4 log
?expressions functions log
?functions log
?log
#log(x) & any & $\log_{e} x$, natural logarithm (base $e$) of $x$ \\
%log(x)@any@$ln~x,$ natural logarithm (base $e$) of $x$
The `log` function returns the natural logarithm (base `e`) of its
argument.
4 log10
?expressions functions log10
?functions log10
?log10
#log10(x) & any & $\log_{10} x$, logarithm (base $10$) of $x$ \\
%log10(x)@any@${log sub 10}~x,$ logarithm (base $10$) of $x$
The `log10` function returns the logarithm (base 10) of its argument.
4 real
?expressions functions real
?functions real
?real
#real(x) & any & real part of $x$ \\
%real(x)@any@real part of $x$
The `real` function returns the real part of its argument.
4 sgn
?expressions functions sgn
?functions sgn
?sgn
#sgn(x) & any & 1 if $x>0$, -1 if $x<0$, 0 if $x=0$. imag($x$) ignored \\
%sgn(x)@any@1 if $x > 0$, -1 if $x < 0$, 0 if $x = 0$. $imag (x)$ ignored
The `sgn` function returns 1 if its argument is positive, -1 if its
argument is negative, and 0 if its argument is 0. If the argument
is a complex value, the imaginary component is ignored.
4 sin
?expressions functions sin
?functions sin
?sin
#sin(x) & radians & $\sin x$, sine of $x$ \\
%sin(x)@radians@$sin~x,$ sine of $x$
The `sin` function returns the sine of its argument. `sin` expects its
argument to be in radians.
4 sinh
?expressions functions sinh
?functions sinh
?sinh
#sinh(x) & radians & $\sinh x$, hyperbolic sine $x$ \\
%sinh(x)@radians@$sinh~x,$ hyperbolic sine $x$
The `sinh` function returns the hyperbolic sine of its argument. `sinh`
expects its argument to be in radians.
4 sqrt
?expressions functions sqrt
?functions sqrt
?sqrt
#sqrt(x) & any & $\sqrt{x}$, square root of $x$ \\
%sqrt(x)@any@$sqrt x $, square root of $x$
The `sqrt` function returns the square root of its argument.
4 tan
?expressions functions tan
?functions tan
?tan
#tan(x) & radians & $\tan x$, tangent of $x$ \\
%tan(x)@radians@$tan~x,$ tangent of $x$
The `tan` function returns the tangent of its argument. `tan` expects
its argument to be in radians.
4 tanh
?expressions functions tanh
?functions tanh
?tanh
#tanh(x) & radians & $\tanh x$, hyperbolic tangent of $x$\\
%tanh(x)@radians@$tanh~x,$ hyperbolic tangent of $x$
The `tanh` function returns the hyperbolic tangent of its argument.
`tanh` expects its argument to be in radians.
@end table
3 operators
?expressions operators
?operators
The operators in GNUPLOT are the same as the corresponding operators
in the C programming language, except that all operators accept
integer, real, and complex arguments, unless otherwise noted.
The ** operator (exponentiation) is supported, as in FORTRAN.
Parentheses may be used to change order of evaluation.
4 binary
?expressions operators binary
?operators binary
?binary
The following is a list of all the binary operators and their
usages:
@start table - first is interactive cleartext form
Symbol Example Explanation
** a**b exponentiation
* a*b multiplication
/ a/b division
% a%b * modulo
+ a+b addition
- a-b subtraction
== a==b equality
!= a!=b inequality
& a&b * bitwise AND
^ a^b * bitwise exclusive OR
| a|b * bitwise inclusive OR
&& a&&b * logical AND
|| a||b * logical OR
?: a?b:c * ternary operation
#\multicolumn{3}{|c|}{Binary Operators} \\
#Symbol & Example & Explanation \\ \hline
#\verb~**~ & \verb~a**b~ & exponentiation\\
#\verb~*~ & \verb~a*b~ & multiplication\\
#\verb~/~ & \verb~a/b~ & division\\
#\verb~%~ & \verb~a%b~ & * modulo\\
#\verb~+~ & \verb~a+b~ & addition\\
#\verb~-~ & \verb~a-b~ & subtraction\\
#\verb~==~ & \verb~a==b~ & equality\\
#\verb~!=~ & \verb~a!=b~ & inequality\\
#\verb~&~ & \verb~a&b~ & * bitwise AND\\
#\verb~^~ & \verb~a^b~ & * bitwise exclusive OR\\
#\verb~|~ & \verb~a|b~ & * bitwise inclusive OR\\
#\verb~&&~ & \verb~a&&b~ & * logical AND\\
#\verb~||~ & \verb~a||b~ & * logical OR\\
#\verb~?:~ & \verb~a?b:c~ & * ternary operation\\
%Symbol@Example@Explanation
%_
%**@a**b@exponentiation
%*@a*b@multiplication
%/@a/b@division
%%@a%b@* modulo
%+@a+b@addition
%-@a-b@subtraction
%==@a==b@equality
%!=@a!=b@inequality
%&@a&b@* bitwise AND
%^@a^b@* bitwise exclusive OR
%|@a|b@* bitwise inclusive OR
%&&@a&&b@* logical AND
%||@a||b@* logical OR
%?:@a?b:c@* ternary operation
@end table
(*) Starred explanations indicate that the operator requires
integer arguments.
Logical AND (&&) and OR (||) short-circuit the way they do in C.
That is, the second && operand is not evaluated if the first is
false; the second || operand is not evaluated if the first is true.
The ternary operator evaluates its first argument (a). If it is
true (non-zero) the second argument (b) is evaluated and returned,
otherwise the third argument (c) is evaluated and returned.
4 unary
?expressions operators unary
?operators unary
?unary
The following is a list of all the unary operators and their
usages:
@start table - first is interactive cleartext form
Symbol Example Explanation
- -a unary minus
~ ~a * one's complement
! !a * logical negation
! a! * factorial
#\multicolumn{3}{|c|}{Unary Operators}\\
#Symbol & Example & Explanation \\ \hline
#\verb@-@ & \verb@-a@ & unary minus \\
#\verb@~@ & \verb@~a@ & * one's complement \\
#\verb@!@ & \verb@!a@ & * logical negation \\
#\verb@!@ & \verb@a!@ & * factorial \\
%-@-a@unary minus
%~@~a@* one's complement
%!@!a@* logical negation
%!@a!@*factorial
@end table
(*) Starred explanations indicate that the operator requires an
integer argument.
The factorial operator returns a real number to allow a greater range.
2 help
?help
The `help` command displays on-line help. To specify information on a
particular topic use the syntax:
help
If is not specified, a short message is printed about
GNUPLOT. After help for the requested topic is given, help for
a subtopic may be requested by typing its name, extending the help
request. After that subtopic has been printed, you may extend the
request again, as before, or go back one level to the previous topic,
by simply pressing return without typing anything. Eventually, you
will return to the GNUPLOT command line.
2 load
?load
The `load` command executes each line of the specified input file as
if it had been typed in interactively. Files created by the `save`
command can later be `load`ed. Any text file containing valid
commands can be created and then executed by the `load` command.
Files being `load`ed may themselves contain `load` commands. See
`comment` for information about comments in commands.
The `load` command must be the last command on the line.
Syntax:
load
The name of the input file must be enclosed in quotes.
Examples:
load 'work.gnu'
load "func.dat"
The `load` command is performed implicitly on any file names given as
arguments to gnuplot. These are loaded in the order specified, and
then gnuplot exits.
2 pause
?pause
Pause is useful in conjunction with `load` files. The command `pause`
displays any text associated with the command and then waits the
specified amount of time. This allows one to build a `load` file
and control the amount of time a finished graph is displayed. The
first argument is an expression that can be -1, 0, or a positive
integer. Choosing -1 will wait until a carriage return is hit. Zero (0)
won't pause at all, and a positive integer (such as 1 or 15) will
wait the specified number of seconds.
Note: Since pause is not part of the plot it may interact with
different device drivers differently (depending upon how text and
graphics are mixed).
Examples:
pause -1 ! Wait until a carriage return is hit
pause 3 ! Wait three seconds
pause -1 "Hit return to continue"
pause 10 "Isn't this pretty? It's a cubic-spline."
Syntax:
pause {"string"}
Note the string is optional, and if present must be enclosed in quotes.
2 plot
?plot
`plot` is the primary command of the program. It plots functions and
data in many, many ways. The full syntax of this command is:
plot {ranges} {title} {style} {, {title} {style}...}
Where is either a mathematical expression, the name of a
data file enclosed in quotes, or a pair of mathematical expressions in
the case of parametric functions. User-defined functions and variables
may also be defined here.
Curly braces {,} denote optional items.
A `plot` command can be as simple as
plot sin(x)
or as complex as (!)
plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
3 data-file
?plot datafile
?plot data-file
?datafile
?data-file
?data
Discrete data contained in a file can displayed by specifying the
name of the data file (enclosed in quotes) on the `plot` command
line.
Data files should contain one data point per line. A data point may
be specified either as an X and Y value separated by blank space, or
as just the Y value, in which case the program will use the number
of the coordinate as the X value. Coordinate numbers start at 0
and are incremented for each data point read. To specify other
formats, see `plot datafile using`. Lines beginning with #
(or ! on VMS) will be treated as comments and ignored.
NOTE that blank lines cause a break in the input, and if the plot
style is `lines` or `linespoints` (see `plot style`) there will be no
line drawn between the preceding and following points. This does not
change the plot style, as would plotting the data as separate curves.
This example compares the data in the file population.dat to a
theoretical curve:
pop(x) = 103*exp((1965-x)/10)
plot [1960:1990] 'population.dat', pop(x)
The file population.dat might contain:
# Gnu population in Antarctica since 1965
1965 103
1970 55
1975 34
1980 24
1985 10
4 using
?plot datafile using
?plot data-file using
?using
The format of data within a file can be selected with the `using`
option. The `xy` and `yx` specify the order of the `x` and `y`
variables in the data file. To reverse the variables specify `yx`.
To specify that the datafile should contain one variable specify `y`.
Syntax:
plot "datafile" { using { xy | yx | y } {"scanf string"} } ...
If the `xy`, `yx` or `y` option is omitted, `xy` is used.
If the scanf string is omitted, the default of `"%f%f"` is used.
Examples:
plot "MyData" using yx "%*f%f%*20[^\n]%f" with lines
This causes data to be read from the file "MyData" using the format
`yx "%*f%f%*20[^\n]%f"`. The meaning of this format is: `%*f`
ignore the first number, `%f` then read in the second and assign to y
(the `yx` option of using), `%*20[^\n]` then ignore 20 non-newline
characters, `%f` then read in the x value.
plot "MyData" using "%f%f", "MyData" using "%f%*f%f"
Causes gnuplot to plot the second and third columns of MyData versus
the first column.
Note: gnuplot first reads a line of the data file into a buffer and
then does a
sscanf(input_buffer, scanf_string, &x, &y);
where `x` and `y` are of type `float`. Any scanf string that specifies
two `float` numbers may be used.
3 parametric
?plot parametric
?parametric
When in parametric mode (`set parametric`) mathematical expressions must
be given in pairs:
plot sin(t),t**2
Data files are plotted as before, except the parametric function
must be fully specified before a data file is given as a plot. In
other words, the x parametric function (sin(t) above) and the y
parametric function (t**2 above) must not be interrupted with any
modifiers or data functions; doing so will generate a syntax error
stating that the parametric function is not fully specified.
Ranges take on a different meaning when in parametric mode. The
first specifiable range on the plot command is the trange, the
next the xrange, and the last is the yrange. The following plot
shows setting the trange to [-pi:pi], the xrange to [-1.3:1.3]
and the yrange to [-1:1] for the duration of the plot:
plot [-pi:pi] [-1.3:1.3] [-1:1] sin(t),t**2
Other modifiers, such as `with` and `title` are required after
the function has been fully specified:
plot sin(t),t**2 with linespoints title 'Parametric example'
3 ranges
?plot ranges
?ranges
The optional range specifies the region of the plot which will be displayed.
Ranges may be provided on the `plot` command line and affect only
that plot, or in the `set xrange` and `set yrange` commands, to
change the default ranges for future plots.
Syntax:
[{dummy-var =} {xmin : xmax}] { [{ymin : ymax}] }
Where dummy-var is the independent variable (the default is `x`,
but this may be changed with the `set dummy` command) and the min
and max terms can be expressions or constants.
Both the min and max terms are optional. The ':' is also optional
if neither a min nor a max term is specified. This allows '[]' to
be used as a null range specification.
Specifying a range in the `plot` command line turns autoscaling for
that axis OFF for that plot. Using one of the `set` range commands
turns autoscaling off for that axis for future plots, unless changed
later. (See `set autoscale`).
Examples:
This uses current ranges:
plot cos(x)
This sets the xrange only:
plot [-10:30] sin(pi*x)/(pi*x)
This is the same, but uses t as the dummy-variable:
plot [t = -10 :30] sin(pi*t)/(pi*t)
This sets both the x and yranges:
plot [-pi:pi] [-3:3] tan(x), 1/x
This sets only the yrange:
plot [] [-2:sin(5)*-8] sin(x)**besj0(x)
This sets xmax and ymin only:
plot [:200] [-pi:] exp(sin(x))
3 style
?plot style
?style
Plots may be displayed in one of four styles: `lines`, `points`,
`linespoints`, `impulses`, or `dots`. The `lines` style connects
adjacent points with lines. The `points` style displays a small
symbol at each point. The `linespoints` style does both `lines` and
`points`. The `impulses` style displays a vertical line from the X
axis to each point. The `dots` style plots a tiny dot at each point;
this is useful for scatter plots with many points.
Default styles are chosen with the `set function style` and
`set data style` commands.
By default, each function and data file will use a different
line type and point type, up to the maximum number of available
types. All terminal drivers support at least six different point
types, and re-use them, in order, if more than six are required.
The LaTeX driver supplies an additional six point types (all variants
of a circle), and thus will only repeat after twelve curves are
plotted with points.
If desired, the actual line type and point type used for a plot can
be specified. Syntax:
with