An Interactive Plotting Program
Thomas Williams & Colin Kelley
Version 3.5 organized by: Alex Woo
Version 3.6a organized by: Alexander Lehmann
Major contributors (alphabetic order):
- John Campbell
- Robert Cunningham
- Gershon Elber
- Roger Fearick
- David Kotz
- Ed Kubaitis
- Russell Lang
- Alexander Lehmann
- Carsten Steger
- Tom Tkacik
- Jos Van der Woude
- Alex Woo
Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley
Mailing list for comments: info-gnuplot@dartmouth.edu
Mailing list for bug reports: bug-gnuplot@dartmouth.edu
This manual is for GNUPLOT version 3.6a
Alex Woo, woo@playfair.stanford.edu
gnuplot
GNUPLOT is a command-driven interactive function plotting program.
For help on any topic, type help followed by the name of the topic.
The new GNUPLOT user should begin by reading the introduction topic (type help introduction) and about the plot command (type help plot). Additional help can be obtained from the USENET newsgroup comp.graphics.gnuplot.
copyright
introduction
cd
clear
command line-editing
comment
environment
exit
expressions
fit
help
if
load
call
pause
plot
print
pwd
quit
replot
reread
reset
save
set-show
shell
splot
start-up
substitution
update
user-defined
bugs
list of demos
copyright
Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley
Permission to use, copy, and distribute this software and its
documentation for any purpose with or without fee is hereby granted,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation.
Permission to modify the software is granted, but not the right to
distribute the modified code. Modifications are to be distributed
as patches to released version.
This software is provided "as is" without express or implied warranty.
AUTHORS
Original Software:
Thomas Williams, Colin Kelley.
Gnuplot 2.0 additions:
Russell Lang, Dave Kotz, John Campbell.
Gnuplot 3.0 additions:
Gershon Elber and many others.
There is a mailing list for gnuplot users. Note, however, that the
newsgroup
comp.graphics.gnuplot
is identical to the mailing list (they
both carry the same set of messages). We prefer that you read the
messages through that newsgroup, to subscribing to the mailing list.
(If you can read that newsgroup, and are already on the mailing list,
please send a message info-gnuplot-request@dartmouth.edu, asking to be
removed from the mailing list.)
The address for mailing to list members is
info-gnuplot@dartmouth.edu
and for mailing administrative requests is
info-gnuplot-request@dartmouth.edu
The mailing list for bug reports is
bug-gnuplot@dartmouth.edu
The list of those interested in beta-test versions is
info-gnuplot-beta@dartmouth.edu
introduction
load "filename"
cd 'dir'
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. When no load files are named, gnuplot enters into an interactive mode.
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, and a vertical bar (|) separates mutually exclusive choices. GNUPLOT keywords or help topics are indicated by backquotes or boldface (where available). Angle brackets (<>) are used to mark replaceable tokens.
For help on any topic, type help followed by the name of the topic.
The new GNUPLOT user should begin by reading about the plot command (type help plot). Simple Plots Demo
cd
The cd command changes the working directory.
cd "<directory-name>"
The directory name must be enclosed in quotes.
cd 'subdir'
cd ".."
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.
command line-editing
The editing commands are as follows:
Line-editing:
^B moves back a single character.
^F moves forward a single character.
^A moves to the beginning of the line.
^E moves to the end of the line.
^H and DEL delete the previous character.
^D deletes the current character.
^K deletes from current position to the end of line.
^L,^R redraws line in case it gets trashed.
^U deletes the entire line.
^W deletes the last word.
History:
^P moves back through history.
^N moves forward through history.
Left Arrow - same as ^B.
Right Arrow - same as ^F.
Ctl Left Arrow - same as ^A.
Ctl Right Arrow - same as ^E.
Up Arrow - same as ^P.
Down Arrow - same as ^N.
The Atari version of readline defines some additional key aliases:
Undo - same as ^L.
Home - same as ^A.
Ctrl Home - same as ^E.
ESC - same as ^U.
Help - help' plus return.
Ctrl Help - help '.
comment
environment
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 start-up), and of course by later explicit changes.
On Unix, AmigaDOS, AtariTOS, MS-DOS and OS/2, 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 AmigaDOS, AtariTOS, MS-DOS and OS/2, 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.
On Unix, AtariTOS and AmigaDOS, SHELL is used for the shell command. On MS-DOS and OS/2, COMSPEC is used for the shell command.
On AmigaDOS, GNUFONT is used for the screen font. For example: "setenv GNUFONT sapphire/14".
On MS-DOS, if the BGI interface is used, the variable BGI is used to point to the full path of the BGI drivers directory. Furthermore SVGA is used to name the Super VGA BGI driver in 800x600 res., and its mode of operation as 'Name.Mode'. E.g., if the Super VGA driver is C:\TC\BGI\SVGADRV.BGI and mode 3 is used for 800x600 res., then: 'set BGI=C:\TC\BGI' and 'set SVGA=SVGADRV.3'.
exit
The commands exit and quit and the END-OF-FILE character will exit GNUPLOT. All these commands will clear the output device (as the clear command does) before exiting.
expressions
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.
abs
acos
arg
asin
atan
besj0
besj1
besy0
besy1
ceil
cos
cosh
erf
erfc
exp
floor
gamma
ibeta
inverf
igamma
imag
invnorm
int
lgamma
log
log10
norm
rand
real
sgn
sin
sinh
sqrt
tan
tanh
abs
acos
arg
The arg function returns the phase of a complex number, in radians.
asin
atan
besj0
besj1
besy0
besy1
ceil
cos
The cos function returns the cosine of its argument. cos expects its argument to be in radians.
cosh
erf
erfc
exp
floor
gamma
ibeta
inverf
The inverf function returns the inverse error function of the real part of its argument.
igamma
imag
The imag function returns the imaginary part of its argument as a real number.
invnorm
int
The int function returns the integer part of its argument, truncated toward zero.
lgamma
log
The log function returns the natural logarithm (base e) of its argument.
log10
The log10 function returns the logarithm (base 10) of its argument.
norm
rand
real
The real function returns the real part of its argument.
sgn
sin
The sin function returns the sine of its argument. sin expects its argument to be in radians.
sinh
sqrt
The sqrt function returns the square root of its argument.
tan
The tan function returns the tangent of its argument. tan expects its argument to be in radians.
tanh
The tanh function returns the hyperbolic tangent of its argument. tanh expects its argument to be in radians. Use of functions and complex variables for airfoils
operators
Parentheses may be used to change order of evaluation.
binary
The following is a list of all the binary operators and their usages:
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
(*) Starred explanations indicate that the operator requires integer arguments.
unary
The following is a list of all the unary operators and their usages:
Symbol Example Explanation
- -a unary minus
~ ~a * one's complement
! !a * logical negation
! a! * factorial
(*) Starred explanations indicate that the operator requires an integer argument.
The factorial operator returns a real number to allow a greater range.
fit
fit <function> <datafile> {using x:y{:dy}} <parameter file> or
fit <function> <datafile> {using x:y{:dy}} via <var1>, <var2>, ...
varname = value
(comments, separated by '#' and blank lines are also possible). The form
varname = value # FIXED
FIT_INDEX: This variable always contains the current data point number
during execution starting with 1. You may use it in your fit
function to implement multiple-branch-fits.
FIT_SKIP: You may specify a positive integer to always skip i data points
during fitting. This increases execution speed by the
price of less exact results.
FIT_LIMIT: may be specified to change the default epsilon limit (1e-5).
When the sum of squared residuals changes between 2 iteration
steps by less than a factor of this number, the fit is
considered as 'converged'.
Environment variables:
FIT_LOG changes the logfile's path from './fit.log' (write permission
is necessary).
FIT_SCRIPT specifies a command to be executed after an user interrupt
Examples:
f(x) = a*x**2 + b*x + c
fit f(x) 'measured.dat' 'start.par'
fit f(x) 'measured.dat' using 3:7 'start.par'
fit f(x) './data/trash.dat' using 1:2:3 via a, b, c
SEE ALSO: update
help
The help command displays on-line help. To specify information on a particular topic use the syntax:
help {<topic>}
if
The if command allows commands to be executed conditionally.
if (<condition>) <command-line>
pi=3
if (pi!=acos(-1)) pause 0 "?Fixing pi!";pi=acos(-1);show variables
?Fixing pi!
Variables:
pi = 3.14159
if (1==2) pause 0 "Never see this";pause 0 "Or this either"
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 loaded. Any text file containing valid commands can be created and then executed by the load command. Files being loaded may themselves contain load (or call) commands. See comment for information about comments in commands.
The load command must be the last command on the line.
Syntax:
load "<input-file>"
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.
call
The call command is identical to the load command with one exception: you can have up to 10 additional parameters to the command (delimited according to the standard parser rules) which can be substituted into the lines read from the file. As each line is read from the called input-file it is scanned for the sequence $ (dollar-sign) followed by a digit (0-9). If found, the sequence is replaced by the corresponding parameter from the call command line. If the parameter was specified as a string in the call line, it is substituted without its enclosing quotes. $ followed by any character other than a digit will be that character. (E.g. use $$ to get a single $.) Providing more than 10 parameters on the call command line will cause an error. A parameter that was not provided, substitutes as nothing. Files being called may themselves contain call or load commands.
The call command must be the last command on the line.
Syntax:
call "<input-file>" <parameter-0> <parm-1> ... <parm-9>
The name of the input file must be enclosed in quotes.
Examples:
if the file 'calltest.gp' contains the line:pause 0 "p0=$0 p1=$1 p2=$2 p3=$3 p4=$4 p5=$5 p6=$6 p7=x$7x"entering the command:
call 'calltest.gp' "abcd" 1.2 + "'quoted'" -- "$2"will display:
p0=abcd p1=1.2 p2=+ p3='quoted' p4=- p5=- p6=$2 p7=xx
pause
The pause command displays any text associated with the command and
then waits a specified amount of time or until the carriage return is
pressed. pause is especially useful in conjunction with load files.Syntax:
pause <time> {"<string>"}<time> may be any integer constant or expression. Choosing -1 will
wait until a carriage return is hit, zero (0) won't pause at all, and
a positive integer 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."
plot
plot {ranges} {<function> | {"<datafile>" {using ...}}}
{title} {style} {, <function> {title} {style}...}splot {ranges} {<function> | {"<datafile>" {index i} {using ...}}}
{title} {style} {, <function> {title} {style}...}plot and splot commands can be as simple as
plot sin(x)splot x * yplot [t=1:10] [-pi:pi*2] tan(t), "data.1" using 2:3 with lines,
t**2 with points
data-file
errorbars
parametric
ranges
index
style
title
data-file
Discrete data contained in a file can be displayed by specifying the
name of the data file (enclosed in quotes) on the plot or splot
command line. Data files should contain one data point per line.
Lines beginning with # (or ! on VMS) will be treated as comments
and ignored. For plots, each data point represents an (x,y)
pair. For splots, each point is an (x,y,z) triple. For plots with
error bars (see plot errorbars), each data point is either
(x,y,ydelta), (x,y,ylow,yhigh), (x,y,xdelta), (x,y,xlow,xhigh), or
(x,y,xlow,xhigh,ylow,yhigh). In all cases, the numbers on each
line of a data file must be separated by blank space. This blank
space divides each line into columns.For plots the x value may be omitted, and for splots the x
and y values may be omitted. In either case the omitted values are
assigned the current coordinate number. Coordinate numbers start at 0
and are incremented for each data point read.To specify other formats, see plot datafile using.
In the plot command, blank lines in the data file cause a break in
the plot. There will be no line drawn between the preceding and
following points if the plot style is lines or linespoints (see
plot style). 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 10When a data file is plotted, samples and isosamples are ignored.
Curves plotted using the plot command are automatically extended to
hold the entire curve. Similarly grid data plotted using the splot
command is automatically extended, using the assumption that isolines
are separated by blank lines (a line with only a CR/LF in it).Implicitly, there are two types of 3-d datafiles. If all the isolines
are of the same length, the data is assumed to be a grid data, i.e.,
the data has a grid topology. Cross isolines in the other parametric
direction (the ith cross isoline passes through the ith point of all the
provided isolines) will also be drawn for grid data. (Note contouring
is available for grid data only.) If all the isolines are not of the
same length, no cross isolines will be drawn and contouring that data
is impossible.For splot, data files may contain more than one mesh and by default
all meshes are plotted. Meshes are separated from each other, in the
file, by double blank lines. To control and splot a single mesh from
a multi mesh file, use the index modifier. See splot index for more.For splot if 3-d datafile and using format (see splot datafile using)
specify only z (height field), a non parametric mode must be specified.
If, on the other hand, x, y, and z are all specified, a parametric
mode should be selected (see set parametric) since data is defining a
parametric surface.A simple example of plotting a 3-d data file is
set parametric
splot 'glass.dat'or
set noparametric
splot 'datafile.dat'where the file datafile.dat might contain:
# The valley of the Gnu.
10
10
1010
5
1010
1
1010
0
10Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ).
Rows are separated by blank lines.On some computer systems with a popen function (UNIX), the datafile
can be piped through a shell command by starting the file name
with a '<'. For example:pop(x) = 103*exp(-x/10)
plot "< awk '{print $1-1965, $2}' population.dat", pop(x)would plot the same information as the first population example
but with years since 1965 as the x axis. If you want to execute
this example, you have to delete all comments from the data file
above or substitute the following command for the first part of the
command above (the part up to the comma):plot "< awk '$0 !~ /^#/ {print $1-1965, $2}' population.dat"It is also possible to apply a single function to the "y" value only,
e.g.plot 'population.dat' thru p(x)For more information about 3-d plotting, see splot.
Simple Plot Demos ,
Non-parametric splot demos , and
Parametric splot demos.
using
plot "datafile" { using { <ycol> |
<xcol>:<ycol> |
<xcol>:<ycol>:<ydelta> |
<xcol>:<ycol>:<xdelta> |
<xcol>:<ycol>:<boxwidth> |
<xcol>:<ycol>:<ylow>:<yhigh> |
<xcol>:<ycol>:<xlow>:<xhigh> |
<xcol>:<ycol>:<xdelta>:<ydelta> |
<xcol>:<ycol>:<ydelta>:<boxwidth> |
<xcol>:<ycol>:<ylow>:<yhigh>:<boxwidth> |
<xcol>:<ycol>:<xlow>:<xhigh>:<ylow>:<yhigh>}
{"<scanf string>"} } ...splot "datafile" { using { <xcol>:<ycol>:<zcol> | <zcol> }
{"<scanf string>"} } ...<xcol>, <ycol>, and <zcol> explicitly select the columns to plot from
a space or tab separated multicolumn data file. If only <ycol> is
selected for plot, <xcol> defaults to 1. If only <zcol> is selected
for splot, then only that column is read from the file. An <xcol> of
0 forces <ycol> to be plotted versus its coordinate number. <xcol>,
<ycol>, and <zcol> can be entered as constants or expressions.If x, y and/or z is time data (dates-times), the columns occupied by
the time (any character, spaces included, is allowed in format string)
counts for one column. The "scanf-string" will not work with timeseries.
See also set timefmt.
Time Data DemoIf yerrorbars (see also plot errorbars) are used for plots,
ydelta (for example, a +/- error) should be provided as the third
column, or ylow and yhigh as third and fourth columns.
If xerrorbars (see also plot errorbars) are used for plots,
xdelta (for example, a +/- error) should be provided as the third
column, or xlow and xhigh as third and fourth columns.If xyerrorbars or boxxyerrorbars (see also plot errorbars) are used for
plots, xlow and xhigh may be provided as third and fourth columns and
ylow and yhigh may be provided as fifth and sixth columns. It is also
possible to have xdelta and ydelta in the third and fourth columns,
respectively.If boxes are used for plots, the third column is used to
specify the width of the box. If boxerrorbars are used, the fourth column (if
"ydelta" is third col), or the fifth column (if "ylow" and "yhigh" are
third and fourth cols) may be used for the box width. See boxerrorbars or
set style for more details.
Note that boxerrorbars is only used for data
with errors in y. Each box starts at the x axis (boxxyerrorbars has different
behavior).
Errorbar demos.Scanf strings override any <xcol>:<ycol>(:<zcol>) choices, except for
ordering of input, e.g.,plot "datafile" using 2:1 "%lf%*lf%lf"causes the first column to be y and the third column to be x.
If the scanf string is omitted, the default is generated based on the
<xcol>:<ycol>(:<zcol>) choices. If the using option is omitted, "%lf%lf"
is used for plot ("%lf%lf%lf%lf" for errorbars plots) and "%lf%lf%lf" is
used for splot.Examples:
plot "MyData" using "%*lf%lf%*20[^\n]%lf" with linesData are read from the file "MyData" using the format
"%*lf%lf%*20[^\n]%lf". The meaning of this format is: "%*lf" ignore the
first number, "%lf" then read in the second and assign to x,
"%*20[^\n]" then ignore 20 non-newline characters, "%lf" then read in
the y value.n=3;
plot "MyData", "MyData" using ncauses GNUPLOT to plot the second and third columns of MyData versus
the first column. The command 'n=4; replot' would then plot the second
and fourth columns of MyData versus the first column.splot "glass.dat" using 1causes GNUPLOT to plot the first coordinate of the points of glass.dat
as the z coordinate while ignoring the other two coordinates.Note: GNUPLOT first reads a line of the data file into a buffer and
then does asscanf(input_buffer, scanf_string, &x, &y{, &z});where 'x', 'y', and 'z' are of type 'float'. Any scanf string that
specifies two (three for splot, three to six for errorbars) float
numbers may be used.
Using Demos.
errorbars
Error bars are supported for 2-d data file plots by reading one to
four additional columns specifying ydelta or ylow and yhigh for
yerrorbars or xdelta or xlow and xhigh for xerrorbars or xdelta, ydelta
or xlow, xhigh, ylow, yhigh for xyerrorbars or boxxyerrorbars.
No support exists for any error bars for splots.In the default situation, GNUPLOT expects to see three or six
numbers on each line of the data file, either (x, y, ydelta),
(x, y, ylow, yhigh), (x, y, xdelta), (x, y, xlow, xhigh),
(x, y, xdelta, ydelta), or (x, y, xlow, xhigh, ylow, yhigh). The
x coordinate must be specified. The order of the numbers must be
exactly as given above. Data files in this format can easily be
plotted with error bars:plot "data.dat" with errorbars (or yerrorbars)
plot "data.dat" with xerrorbars
plot "data.dat" with xyerrorbars
plot "data.dat" with yerrorbarsThe y-error bar is a vertical line plotted from (x, ylow) to (x,
yhigh). If ydelta is specified instead of ylow and yhigh,
ylow=y-ydelta and yhigh=y+ydelta are derived. If there
are only two numbers on the line, yhigh and ylow are both set to
y. The x-error bar is a horizontal line computed in the same fashion.
To get lines plotted between the data points, plot the data file
twice, once with errorbars and once with lines.If autoscaling is on, the x and/or y range will be adjusted to fit the
error bars.The using option may be used to specify how columns of the data file
are to be assigned to x, y, ydelta, ylow and yhigh, xdelta, xlow and xhigh.
The x column must
be provided and both the x and y columns must appear before the
errorbar columns. If three column numbers are given, they are x, y,
and ydelta or xdelta. If four columns are given, they are x, y, ylow,
and yhigh or x, y, xlow, and xhigh or x, y, xdelta, ydelta.Examples:
plot "data.dat" using 1:2:3:4 with errorbars (or yerrorbars)
plot "data.dat" using 3:2:6 with xerrorbars
plot "data.dat" using 3:4:8:7 with xyerrorbarsThe first example reads, x, y, ylow, and yhigh, from columns 1, 2, 3,
and 4. This is equivalent to the default. The second example reads x
from the third column, y from second and xdelta from the sixth column.
The third example reads x from the third column, y from the fourth,
xdelta from the eighth, and ydelta from seventh columns.
Errorbar demos.See also plot using and plot style.
parametric
When in parametric mode (set parametric) mathematical expressions must
be given in pairs for plot and in triplets for splot:plot sin(t),t**2or
splot cos(u)*cos(v),cos(u)*sin(v),sin(u)Data files are plotted as before, except any preceding 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
range on the plot command is the trange, the next is the xrange,
and the last is the yrange. For splot the order is urange,
vrange, xrange, yrange, and finally zrange. The following
plot command 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**2Other modifiers, such as with and title, may be specified only
after the parametric function has been completed:plot sin(t),t**2 title 'Parametric example' with linespoints
ranges
The optional range specifies the region of the plot that will be
displayed.Ranges may be provided on the plot and splot command line and
affect only that plot, or in the set xrange, set yrange, etc.,
commands, to change the default ranges for future plots.Syntax:
[{<dummy-var> =} {<xmin> : <xmax>}] { [{<ymin> : <ymax>}] }where <dummy-var> is the independent variable (the defaults are x and
y, but this may be changed with set dummy) and the min and max
terms can be constant expressions. If only one value is provided
(as in: set yrange [0:]) the range in the opposite direction is
unaffected (or still autoscaled). To set a range back to autoscale
give a star as the value (set yrange [*:] turns autoscaling in
the ymin direction on).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).With time data, provide the ranges in the samme manner as in the datafile
within quotes (uses the timefmt string to read the value).Examples:
This uses the current ranges:
plot cos(x)This sets the x range 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 y ranges:
plot [-pi:pi] [-3:3] tan(x), 1/xThis sets only the y range, and turns off autoscaling on both axes:
plot [ ] [-2:sin(5)*-8] sin(x)**besj0(x)This sets xmax and ymin only:
plot [:200] [-pi:] exp(sin(x))This sets the x, y, and z ranges:
splot [0:3] [1:4] [-1:1] x*yTimeseries (timefmt="%d/%m/%y %H:%M"):
set xrange ["1/6/93 12:00":"5/6/93 12:00"]
index
splot "data1" index 2 with points
will splot the third mesh in file data1 with points.
splot with indices demo.
style
Plots may be displayed in one of thirteen styles: lines, points,
linespoints, impulses, dots, {x,y,xy}errorbars, steps, fsteps,
boxes, boxerrorbars, or boxxyerrorbars. 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
(or from the grid base for splot) to each point. The dots style
plots a tiny dot at each point; this is useful for
scatter plots with many points.The errorbars (or yerrorbars) and xerrorbars styles are only relevant to
2-d data file plotting. It
is treated like points for splots and function plots. For data
plots, errorbars is like points, except that a vertical or
horizontal error bar is also drawn: for each point (x,y), a line is
drawn from (x,ylow) to (x,yhigh) or (xlow,y) to (xhigh,y). A tic mark is
placed at the ends of the error bar. The (ylow, yhigh) or (xlow,xhigh)
values are read from the data file's columns, as specified with the using
option to plot. See plot errorbars for more information.The boxes style is only relevant to 2-d plotting. Another style
called boxerrorbars is also available and is only relevant to 2-d
data file plotting. This style is a combination of the boxes and
errorbars styles. The boxes style draws a box centred about
the given x coordinate from the yaxis to the given y coordinate.
The width of the box is obtained in one of three ways. First, if a
data file has a fifth column, this will be used to set the width of
the box. Columns 3 and 4 (for boxerrorbars) are necessary but
ignored in this instance. Secondly, if a width has been set using
the set boxwidth command, this will be used. Otherwise the width
of each box will be calculated automatically so that it touches the
adjacent boxes.The boxes style is only relevant to 2-d plotting. It draws
a box centred about the given x coordinate from the yaxis to the given
y coordinate. The width of the box is obtained in one of three
ways. If a data file has a third column, this will be used to set
the width of the box. Otherwise, if a width has been set using the
set boxwidth command, this will be used. Otherwise the width of each
box will be calculated automatically so that it touches the adjacent
boxes. Another style called boxerrorbars is also available and is
only relevant to 2-d data file plotting. This style is a combination
of the boxes and errorbars styles. The boxwidth will come from the fourth
column if the y errors are in the form of "ydelta" and the boxwidth was not
previously set equal to -2.0 (set boxwidth -2.0) or from the fifth
column if the y errors are in the form of "ylow yhigh". The boxwidth = -2.0 is
for the special case of 4-column data and the y errors are in the form of
"ylow yhigh". The boxwidth will be calculated automatically so that each box
touches the adjacent boxes. The width will also be automatically calculated
if 3-column data is used. The boxxyerrorbars
style is like the xyerrorbars option except that a box with width
(xhigh-xlow) and height (yhigh-ylow) is drawn instead of a cross of that size.For 2-d data with more than two columns, gnuplot will be picky about the
allowed plot styles. For three columns only xerrorbars, boxes,
errorbars (or yerrorbars), and boxerrorbars are allowed. If another plot
style is used,
the style will be changed to yerrorbars. The boxerrorbars style will
calculate the boxwidth automatically. For four columns only xerrorbars,
xyerrorbars, boxxyerrorbars, boxerrorbars, and errorbars (or
yerrorbars) are allowed. An illegal plot style will be changed to
yerrorbars. Five column data allows only the boxerrorbars style. An
illegal style will be changed to boxerrorbars before plotting. Six and
seven column data only allows the xyerrorbars and boxxyerrorbars styles.
Illegal styles will be changed to xyerrorbars before plotting. Use the
using option for plot to setup the correct number of columns for the
style you want.
The steps and fsteps styles is only relevant to 2-d plotting.
The steps style connects consecutive points with two line segments:
the first from (x1,y1) to (x2,y1) and the second from (x2,y1) to (x2,y2).
The fsteps: (x1,y1) to (x1,y2) and (x1,y2) to (x2,y2).
Steps Demo.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 style and (optionally) the line type and point type
used for a curve can be specified.Syntax:
with <style> {<linetype> {<pointtype>}}where <style> is either lines, points, linespoints, impulses,
dots, steps, fstepsm {x,y,xy}errorbars, boxes, boxerrorbars,
or boxxyerrorbars. The <linetype> and <pointtype> are
positive integer constants or expressions and specify the line type
and point type to be used for the plot. Line type 1 is the first line
type used by default, line type 2 is the second line type used by
default, etc.Examples:
This plots sin(x) with impulses:
plot sin(x) with impulsesThis plots x*y with points, x**2 + y**2 default:
splot x*y w points, x**2 + y**2This plots tan(x) with the default function style, "data.1" with lines:
plot [ ] [-2:5] tan(x), "data.1" with lThis plots "leastsq.dat" with impulses:
plot 'leastsq.dat' w iThis plots the data file 'population' with boxes:
plot "population" with boxesThis plots "exper.dat" with errorbars and lines connecting the points:
plot 'exper.dat' w lines, 'exper.dat' w errorbarsHere 'exper.dat' should have three or four data columns.
This plots x**2 + y**2 and x**2 - y**2 with the same line type:
splot x**2 + y**2 with line 1, x**2 - y**2 with line 1This plots sin(x) and cos(x) with linespoints, using the
same line type but different point types:plot sin(x) with linesp 1 3, cos(x) with linesp 1 4This plots file "data" with points style 3:
plot "data" with points 1 3Note that the line style must be specified when specifying the point
style, even when it is irrelevant. Here the line style is 1 and the
point style is 3, and the line style is irrelevant.See set style to change the default styles.
title
A title of each plot appears in the key. By default the title is
the function or file name as it appears on the plot command line.
The title can be changed by using the title option. This option
should precede any with option.Syntax:
title "<title>"where <title> is the new title of the plot and must be enclosed in
quotes. The quotes will not be shown in the key. Special characters
may be given as backslash and their octal value (\345), \t is
anderstood.Examples:
This plots y=x with the title 'x':
plot xThis plots the "glass.dat" file with the title 'surface of revolution':
splot "glass.dat" title 'surface of revolution'This plots x squared with title "x^2" and "data.1" with title
'measured data':plot x**2 title "x^2", "data.1" t 'measured data'The title can be omitted from the key with the "notitle" option for
plot and splot. This can be useful when some curves
are plotted solely for decoration; for example, if one wanted a
circular border for a polar plot, he could say:Example:
set polar
plot my_function(x), 1 notitleThis would generate a key entry for "my_function" but not for "1".
See the poldat.dem example.
The print command prints the value of <expression> to the screen.
print <expression>
pwd
The pwd command prints the name of the working directory to the screen.
pwd
quit
The exit and quit commands and END-OF-FILE character will exit
GNUPLOT. All these commands will clear the output device (as the
clear command does) before exiting.
replot
The replot command without arguments repeats the last plot or splot
command. This can be useful for viewing a plot with different set
options, or when generating the same plot for several devices.Arguments specified after a replot command will be added onto the last
plot (splot) command (with an implied ',' separator) before it is
repeated. replot accepts the same arguments as the plot (splot)
commands except that ranges cannot be specified.
See command line-editing for ways to edit the last plot
(splot) command.
reread
The reread command causes the current gnuplot command file, as specified
by a load command or on the command line, to be reset to its starting
point before further commands are read from it. This essentially implements
an endless loop of the commands from the beginning of the command file to
the reread command. The reread command has no effect if input from
standard input.
Reread Animation
reset
The reset command causes all options that can be set with the
set-command to take on their default values. The only exceptions are
that the terminal set with set term and the output file set with
set output are left unchanged. This command is useful e.g. to restore
the default settings at the end of a command file, or to return to a
defined state after lots of settings have been changed within a command
file. Please refer to the set command to see the default values that
the respective options take.
save
The save command saves user-defined functions, variables, set
options or all three plus the last plot (splot) command to the
specified file.Syntax:
save {<option>} "<filename>"where <option> is functions, variables or set. If no option is
used, GNUPLOT saves functions, variables, set options and the last plot
(splot) command.saved files are written in text format and may be read by the load
command.The filename must be enclosed in quotes.
Examples:
save "work.gnu"
save functions 'func.dat'
save var 'var.dat'
save set "options.dat"
set-show
The set command sets LOTS of options.
The show command shows their settings. show all shows all the
settings.
angles
arrow
autoscale
border
boxwidth
clabel
clip
cntrparam
contour
data style
dgrid3d
dummy
format
function style
functions
grid
hidden3d
isosamples
key
keytitle
label
logscale
mapping
offsets
output
parametric
pointsize
polar
rrange
samples
size
style
surface
terminal
tics
time
timefmt
title
trange
urange
variables
view
vrange
xdata
xlabel
xmargin
xrange
xtics
mxtics
mytics
xdtics
xmtics
xzeroaxis
ydata
ylabel
yrange
ytics
ydtics
ymtics
yzeroaxis
zdata
zero
zeroaxis
zlabel
zrange
ztics
zdtics
zmtics
angles
By default, GNUPLOT assumes the independent variable in polar plots
is in units of radians. If set angles degrees is specified before
set polar then the default range is [0:360] and the independent
variable has units of degrees. This is particularly useful for
plots of data files. The angle setting also hold for the 3-d
mapping as set via the set mapping command.Syntax:
set angles { degrees | radians }
show angles
arrow
Arbitrary arrows can be placed on a plot using the set arrow
command.set arrow {<tag>} {from <sx>,<sy>{,<sz>}}
{to <ex>,<ey>{,<ez>}} {{no}head}
set noarrow {<tag>}
show arrowUnspecified coordinates default to 0. The x, y, and z values are in
the graph's coordinate system. The z coordinate is only used in
splot commands. <tag> is an integer that identifies the arrow. If no
tag is given, the lowest unused tag value is assigned automatically.
The tag can be used to delete or change a specific arrow. To change
any attribute of an existing arrow, use the set arrow command with
the appropriate tag, and specify the parts of the arrow to be
changed. Specifying nohead requests the arrow be drawn without a head
(yielding a line segment). By default, arrows have heads.Arrows outside the plotted boundaries are permitted but may cause
device errors.Examples:
To set an arrow pointing from the origin to (1,2), use:
set arrow to 1,2To set an arrow from (-10,4,2) to (-5,5,3), and tag the arrow number
3, use:set arrow 3 from -10,4,2 to -5,5,3To change the preceding arrow begin at 1,1,1, without an arrow head,
use:set arrow 3 from 1,1,1 noheadTo delete arrow number 2 use:
set noarrow 2To delete all arrows use:
set noarrowTo show all arrows (in tag order) use:
show arrow
autoscale
When autoscaling, the plot range is automatically computed and the
dependent axis (y for a plot and z for splot) is scaled to
include the range of the function or data being plotted.If autoscaling of the dependent axis (y or z) is not set, the
current y or z range is used.See set yrange or set zrange.
Autoscaling the independent variables (x for plot and x,y for
splot) is a request to set the domain to match any data file being
plotted. If there are no data files then autoscaling an independent
variable has no effect. In other words, in the absence of a data
file, functions alone do not affect the x range (or the y range if
plotting z = f(x,y)).See set xrange, or set yrange.
The behavior of autoscaling remains consistent in parametric mode,
however, there are more dependent variables and hence more control
over x, y, and z plot scales. In parametric mode, the independent or
dummy variable is t for plots and u,v for splots. Autoscale in
parametric mode, then, controls all ranges (t, u, v, x, y, and z) and
allows x, y, and z to be fully autoscaled.See set parametric.
Syntax:
set autoscale <axes>
set noautoscale <axes>
show autoscalewhere <axes> is either x, y, z or xy. If <axes> is not given
then all axes are assumed.Examples:
This sets autoscaling of the y axis. x axis autoscaling is not
affected.set autoscale yThis sets autoscaling of the x and y axes.
set autoscale xyThis sets autoscaling of the x, y and z axes.
set autoscaleThis disables autoscaling of the x, y and z axes.
set noautoscaleThis disables autoscaling of the z axis only.
set noautoscale z
parametric mode
When in parametric mode (set parametric) the xrange is as
fully scalable as the yrange. In other words, in parametric
mode the x axis can be automatically scaled to fit the range
of the parametric function that is being plotted. Of course,
the y axis can also be automatically scaled just as in the
non-parametric case. If autoscaling on the x axis is not set,
the current x range is used.When there is a mix of data files and functions, the xrange of
the functions is selected as that of the data files if autoscale
is true for x. While this keeps the behavior compatible with
non-parametric plotting, it may not be retained in the future.
The problem is that, in parametric mode, the x and y ranges are
not as distinguishable as in the non-parametric mode and this
behavior may not be the most useful.For completeness a last command set autoscale t is accepted.
However, the effect of this "scaling" is very minor. When
GNUPLOT determines that the t range would be empty it makes a
small adjustment if autoscaling is true. Otherwise, GNUPLOT
gives an error. Such behavior may, in fact, not be very useful
and the command set autoscale t is certainly questionable.splot extends the above idea similarly. If autoscaling is set then
x, y, and z ranges are computed and each axis scaled to fit the
resulting data.
border
The set border and set noborder commands controls the display of
the plot borders for the plot commands. The borders
are encoded in a four bit integer:SOUTH 0th bit
WEST 1st bit
NORTH 2nd bit
EAST 3rd bitTo facilitate two y-scales, the tic marks and labels will only be
written to the EAST and NORTH borders if the opposite border is off.Syntax:
set border (turns on all borders)
set border 3 (only SOUTHWEST borders)
set border 12 (only NORTHEAST borders with tics on top and right)
set noborder
show bordere.g
Borders Demo.
boxwidth
The set boxwidth command is used to set the default width of
boxes in the boxes and boxerrorbars styles.If a data file is plotted without the width being specified in the
third to fifth columns, or a function is plotted, the width of each box is
set by the set boxwidth command. If a width is given after the
set boxwidth command then this is used as the width. Otherwise
the width of each box will be calculated automatically so that
it touches the adjacent boxes. Four-column data may have the width be
calculated automatically if the width is first set to -2.0. Otherwise, the
fourth column will be interpreted as the box width. See boxerrorbars or
set style for more details.Syntax:
set boxwidth {<width>}
show boxwidthTo set the box width to automatic use the command
set boxwidth
set boxwidth -2 (4-col data)
clabel
set clabel
set noclabel
show clabel
clip
GNUPLOT can clip data points and lines that are near the boundaries
of a plot.set clip <clip-type>
set noclip <clip-type>
show clipThree clip types are supported by GNUPLOT: points, one, and two.
One, two, or all three clip types may be active for a single plot.The points clip type forces GNUPLOT to clip (actually, not plot at
all) data points that fall within but too close to the boundaries
(this is so the large symbols used for points will not extend outside
the boundary lines). Without clipping points near the boundaries may
look bad; try adjusting the x and y ranges.Setting the one clip type causes GNUPLOT to plot the line segments
which have only one of the two endpoints within the plotting region.
Only the in-range portion of the line is drawn. The alternative is to
not draw any portion of the line segment.Some lines may have both endpoints out of range, but pass through the
plotting area. Setting the two clip-type allows the visible portion
of these lines to be drawn.In no case is a line drawn outside the plotting area.
The defaults are noclip points, clip one, and noclip two.
To check the state of all forms of clipping, use
show clipFor backward compatibility with older versions, the following forms
are also permitted.set clip
set noclipset clip is synonymous with set clip points. set noclip turns
off all three types of clipping.
cntrparam
Sets the different parameters for the contouring plot (see also contour).
Syntax:
set cntrparam { { linear | cubicspline | bspline } |
points <n> |
order <n> |
levels { [ auto ] <n> |
discrete <z1>,<z2>, ... |
incremental {<start>, <incr>{, <end>} } }Examples:
set cntrparam bspline
set cntrparam points 7
set cntrparam order 10
set cntrparam levels auto 5 # 5 automatic levels
set cntrparam levels discrete .1,1/exp(1),.9 # 3 discrete at .1,.37,.9
set cntrparam levels incremental 0,.1,.4
# 5 incremental levels at 0, .1, .2, .3 and .4
set cntrparam levels 10
# sets n = 10 retaining current setting of auto, discr. and
# increment's start and increment value, while changing end
set cntrparam levels incremental 100,50
# set start = 100 and increment = 50, retaining n levelsThis command controls the way contours are plotted. <n> should be an
integral constant expression and <z1>, <z2> any constant expressions.
The parameters are:linear, cubicspline, bspline - Controls type of approximation or
interpolation. If linear, then the contours are drawn piecewise
linear, as extracted from the surface directly. If cubicspline, then
piecewise linear contours are interpolated to form a somewhat smoother
contours, but which may undulate. The third option is the uniform
bspline, which only approximates the piecewise linear data but is
guaranteed to be smoother.points - Eventually all drawings are done with piecewise linear
strokes. This number controls the number of points used to
approximate a curve. Relevant for cubicspline and bspline modes
only.order - Order of the bspline approximation to be used. The bigger this
order is, the smoother the resulting contour. (Of course, higher order
bspline curves will move further away from the original piecewise linear
data.) This option is relevant for bspline mode only. Allowed values are
integers in the range from 2 (linear) to 10.levels - Number of contour levels, 'n'. Selection of the levels is
controlled by 'auto' (default), 'discrete', and 'incremental'. For 'auto',
if the surface is bounded by zmin and zmax then contours will be
generated from zmin+dz to zmax-dz in steps of size dz, where
dz = (zmax - zmin) / (levels + 1). For 'discrete', contours will be
generated at z = z1, z2 ... as specified. The number of discrete levels
is limited to MAX_DISCRETE_LEVELS, defined in plot.h to be 30. If
'incremental', contours are generated at <n> values of z beginning at
<start> and increasing by <increment>.
Contours Demo and
contours with User Defined Levels.
contour
Enable contour drawing for surfaces. This option is available for splot
only.Syntax:
set contour { base | surface | both }
set nocontourIf no option is provided to set contour, the default is base.
The three options specify where to draw the contours: base draws
the contours on the grid base where the x/ytics are placed, surface
draws the contours on the surfaces themselves, and both draws the
contours on both the base and the surface.See also set cntrparam for the parameters that affect the drawing of
contours.
Contours Demo and
contours with User Defined Levels.
data style
The set data style command changes the default plotting style
for data plots.set data style
show data style
set data style <style-choice>In the first case, set data style returns the possible style
choices: lines, points, linespoints, dots, steps,
impulses, {x,y,xy}errorbars, boxes, boxerrorbars or
boxxyerrorbars. show data style shows the current default plotting
style for data. set data style dots would actually change the default
plotting style. See also plot.
dgrid3d
Enables and sets the different parameters for non grid to grid data mapping.
set dgrid3d {,{<row_size>}{,{<col_size>}{,<norm>}}}
set nodgrid3dset dgrid3d 10,10,2
set dgrid3d ,,4This dgrid3d option is a simple low pass filter that converts scattered data
to a grid data set. More sophisticated approaches to this problem exists and
should be used as a preprocess to and outside gnuplot if this simple solution
is found inadequate.
Dgrid3d Demo.
dummy
By default, GNUPLOT assumes that the independent variable for the
plot command is x, and the independent variables for the splot
command are x and y. They are called the dummy variables because it
is just a notation to indicate the independent variables.
The set dummy command changes these default dummy variable names.
For example, it may be more convenient to call the dummy variable t
when plotting time functions:set dummy t
plot sin(t), cos(t)Syntax:
set dummy <dummy-var>{,<dummy-var>}
show dummyExamples:
set dummy u,v
set dummy ,sto set both dummy variables to u and v or set only the second
variable to s.The set parametric command also changes the dummy variables (to t
for plot and u,v for splots).
format
The format of the tic-mark labels can be set with the set format
command. The default format for both axes is "%g", but other formats
such as "%.2f" or "%3.0fm" are often desirable. Anything accepted by
printf when given a double precision number, and then accepted by the
terminal, will work. In particular, the formats f, e, and g will work,
and the d, o, x, c, s, and u formats will not work. If data type for the
axis is date/time, the format string must contain valid codes for the
strftime function (do: man strftime). It's recommended to stick to the
conversion codes accepted by the set timefmt command. If the format
string looks like a floating point format, then gnuplot tries to construct
a reasonable format.Syntax:
set format {<axes>} {"<format-string>"}
show formatwhere <axes> is either x, y, z, xy, or nothing (which is the
same as xy). The length of the string representing a ticmark (after
formatting with printf) is restricted to 100 characters. If the
format string is omitted, the format will be returned to the default
"%g". For LaTeX users, the format "$%g$" is often desirable. If the
empty string "" is used, no label will be plotted with each tic,
though the tic mark will still be plotted. To eliminate all tic marks,
use set noxtics or set noytics.For plot newlines (\n) is accepted in the xaxis format string, and
for splot newlines is allowed for both x- and yaxis format strings.See also set xtics and set ytics for more control over tic labels.
function style
The set function style command changes the default plotting style
for functions.set function style
show function style
set function style <style-choice>In the first case, set function style returns the possible style
choices: lines, points, linespoints, dots, steps,
impulses, {x,y,xy}errorbars, boxes, boxerrorbars, or
boxxyerrorbars.
show function style shows the current default plotting style for
functions. set function style linespoints would actually change
the default plotting style. See also plot.
functions
The show functions command lists all user-defined functions and
their definitions.show functionse.g.
Splines as User Defined Functions.
and
Use of functions and complex variables for airfoils
grid
set grid {mxtics OR mytics}
set nogrid
show grid
hidden3d
The set hidden3d command enables hidden line removal for explicit
surface plotting (see splot).
Hidden line removal may be used for both explicit functions and for
explicit data. It now works for parametric surfaces as well.When this flag is set both the surface hidden portion and possibly
its hidden contours (see set contour) as well as the hidden grid will be
removed. Labels and arrows are always visible and are unaffected by this
command.Each surface has its hidden parts removed with respect to itself and to
other surfaces, if more than one surface is plotted. This mode is
meaningful when surfaces are plotted using line style drawing only.Syntax:
set hidden3d
set nohidden3d
show hidden3de.g.
Hidden Line Removal Demo and
Complex Hidden Line Demo.
isosamples
set isosamples <iso_1> {,<iso_2>}
show isosamplesWhen a surface plot is being done without the removal of hidden
lines, set samples also has an effect on the number of points being
evaluated. See set samples.
key
set key
set key <x>,<y>{,<z>}
set key <keyword> {<keyword> {<justification>}}
set nokey
show keyThe coordinates <x>, <y> (and <z> for splots) specify the location
of the key on the plot. The key is drawn as a sequence of lines, with
one plot described on each line. On the right hand side of each line
is a representation that attempts to mimic the way the curve is
plotted. On the left side of each line is the text description,
obtained from the plot command. See plot title to change this
description. The lines are vertically arranged so an imaginary
straight line divides the left- and right-hand sides of the key. It is
the coordinates of this line that are specified with the set key
command. In a plot, only the x and y coordinates are used to specify
the line position. For a splot, x, y and z are all being used as a
3-d location mapped using the same mapping as the plot itself to form
the required 2-d screen position of the imaginary line.Some or all of the key may be outside of the plot boundary, although
this may interfere with other labels and may cause an error on some
devices. If you use the keywords outside or below, gnuplot makes
space for the keys and the plot becomes smaller. Putting keys outside
to the right, they occupy as few colums as possible, and putting them
below, as many culumns as possible (depending of the length of the
labels). Thus stealing as little space from the plot as possible.Examples:
This places the key at the default location:
set keyThis disables the key:
set nokeyThis places a key at coordinates 2,3.5,2
set key 2,3.5,2Put the keys below the plot
set key belowPlace the beys in the bottom left corner and justify the text left:
set key left bottom LeftPut it in the default corner:
set key
keytitle
This command allows a key header to the printed above the keys.
set keytitle "<string>"
label
Arbitrary labels can be placed on the plot using the set label
command. If the z coordinate is given on a plot it is ignored; if
it is missing on a splot it is assumed to be 0. The strings is scanned
for backslash-octal (\nnn) conversion.Syntax:
set label {<tag>} {"<label_text>"} {at <x>,<y>{,<z>}}
{<justification>}
set nolabel {<tag>}
show labelThe text defaults to "", and the position to 0,0,0. The <x>, <y>, and
<z> values are in the graph's coordinate system. The tag is an
integer that is used to identify the label. If no <tag> is given, the
lowest unused tag value is assigned automatically. The tag can be used
to delete or change a specific label. To change any attribute of an
existing label, use the set label command with the appropriate tag,
and specify the parts of the label to be changed.By default, the text is placed flush left against the point x,y,z.
To adjust the way the label is positioned with respect to the point
x,y,z, add the parameter <justification>, which may be left, right
or center, indicating that the point is to be at the left, right or
center of the text. Labels outside the plotted boundaries are
permitted but may interfere with axes labels or other text.If one (or more) axis is timeseries, the coordiate should be given as
a quoted time string according to the timefmt-format string. See
set {x,y,z}data and set timefmt.Examples:
To set a label at (1,2) to "y=x" use:
set label "y=x" at 1,2To set a label "y=x^2" with the right of the text at (2,3,4), and tag
the label number 3, use:set label 3 "y=x^2" at 2,3,4 rightTo change the preceding label to center justification, use:
set label 3 centerTo delete label number 2 use:
set nolabel 2To delete all labels use:
set nolabelTo show all labels (in tag order) use:
show labelTimeseries (timefmt="%d/%m/%y,%H:%M):
set label "Harvest" at "25/8/93",1(The EEPIC, Imagen, LaTeX, and TPIC drivers allow \\ in a string to specify
a newline.)
logscale
Log scaling may be set on the x, y, and z axes.
set logscale <axes> <base>
set nologscale <axes>
show logscaleTo enable log scaling in both x and z axes:
set logscale xzTo enable scaling log base 2 of the y axis:
set logscale y 2To disable z axis log scaling:
set nologscale z
mapping
set mapping { cartesian | spherical | cylindrical }Data for splots are usually in regular Euclidean space and are
provided in Cartesian coordinates. Such 3-d data require three
coordinates (x, y and z) or one coordinate (only z) in each line in
the data file. In order to be able to use spherical or cylindrical
coordinate systems, use the set mapping command. In both cases two
coordinates are expected in each line of the data. For a spherical
coordinate system, these are theta and phi (in units as specified by
set angles) and the mapping is:x = cos( theta ) * cos( phi )
y = sin( theta ) * cos( phi )
z = sin( phi )For a cylindrical coordinate system, the mapping uses two variables,
theta (in units as specified by set angles) and z:x = cos( theta )
y = sin( theta )
z = zAgain, note that mapping will affect data file splots only.
Mapping Demos.
offsets
The amount of the graph that the plot takes up may be controlled to
some extent with the set offsets command. This command takes four
offset arguments: <left>, <right>, <top> and <bottom>. By default,
each offset is 0. Each offset may be a constant or an expression. Left
and right offsets are given in units of the x axis, while top and
bottom offsets are given in units of the y axis. The plot of sin(x),
displayed with offsets of 0, 0, 2, 2 will take up 1/3 of the
displayed y axis. Offsets are particularly useful with polar
coordinates as a means of compensating for aspect ratio distortion.
Offsets are ignored in splots.Syntax:
set offsets <left>, <right>, <top>, <bottom>
show offsets
output
set output {"<filename>"}
show outputset output "|lpr -Plaser filename"
set output "|lp -dlaser filename"(On MSDOS machines, set output "prn" will direct the output
to the default printer.)
parametric
The set parametric command changes the meaning of plot (splot)
from normal functions to parametric functions. The command
set noparametric changes the plotting style back to normal,
single-valued expression plotting.In 2-d plotting, a parametric function is determined by a pair
of parametric functions operating on a parameter. An example
of a 2-d parametric function would be plot sin(t),cos(t) (which
defines a circle).For 3-d plotting, the surface is described as x=f(u,v), y=g(u,v),
z=h(u,v). Therefore a triplet of functions are required. An example of
3-d parametric function would be cos(u)*cos(v),cos(u)*sin(v),sin(u)
(which defines a sphere). It takes three parametric function
specifications in terms of the parametric dummy arguments to describe
a single graph.The total set of possible plots is a superset of the simple f(x)
style plots, since the two (three) functions can describe the
x and y (and z) values to be computed separately. In fact,
plots of the type t,f(t) (u,v,f(u,v)) are equivalent to those
produced with f(x) when the x values are computed using the
identity function as the first function.Note that the order the parametric functions are specified is
xfunction, yfunction (and zfunction) and that each operates over the
common parametric domain.Also, the set parametric function implies a new range of values.
Whereas the normal f(x) and f(x,y) style plotting assume an xrange
and yrange (and zrange), the parametric mode additionally specifies a
trange, urange, and vrange. These ranges may be set
directly with set trange, set urange and set vrange, or by
specifying the range on the plot or splot commands. Currently
the default range for these parametric variables is [-5:5].
Setting the ranges to something more meaningful is expected.
pointsize
Please note that the pointsize setting is not supported with all terminal
types.
polar
The set polar command changes the meaning of the plot from
rectangular coordinates to polar coordinates. In polar coordinates,
the dummy variable (x) is an angle. The range of this angle is changed
from whatever it was to [0:2*pi], or, if degree unit has been selected,
to [0:360] (see set angles).The command set nopolar changes the meaning of the plot back to the
default rectangular coordinate system. The range of x is changed from
whatever it was to [-10:10].The set polar command is not supported for splots. See the
set mapping command for similar functionality for splots.While in polar coordinates the meaning of an expression in x is really
r = f(x), where x is an angle of rotation. The xrange controls the
domain (the angle) of the function, and the yrange controls the range
(the radius). The plot is plotted in a rectangular box, and the x and
y axes are both in units of the radius. Thus, the yrange controls both
dimensions of the plot output. The tics and units are written along
the axes rather than at the left and bottom. These unit are offset by
<rmin> specified by the rrange (See set rrange). It is not
possible to specify different output dimensions in the x or y
directions. The yrange can be used to shift the plot diagonally to
display only the first or third quadrants.Syntax:
set polar
set nopolar
show polarExample:
set polar
plot x*sin(x)
plot [-2*pi:2*pi] [-3:3] x*sin(x)The first plot uses the default polar angular domain of 0 to 2*pi.
The radius (and the size of the plot) is scaled automatically. The
second plot expands the domain, and restricts the range of the radius
(and the size of the plot) to [-3:3].
Polar demos
Polar Data Plot.
rrange
The set rrange command sets the radial range used to compute x and y
values when in polar mode. If not in polar mode (see set polar) then
this range is not used. Use of this command offsets the polar
singularity to the <rmin> value and shifts the units on the axes tic
marks. For instance, set rrange [-40:40] would set the origin to -40
and would plot values of radial values between -40 to 40. Thus, if
360 degrees of data were plotted, then the plot would extend 80 units
in radially from the origin. To view the entire plot, a
set yrange [-80:80] command would create a square viewport with
a circular plot tangent at the axes. Because xrange is used
specify the angular extent, only a square viewport can be specified
by yrange. For instance, set yrange [0:80] would display the
first quadrant and set yrange [-80:0] would display the third
quadrant. Any square viewport of any size can be specified but it
is constrained to be centered on a 45 degree line.This range may also be specified on the plot command line when in
polar mode.Syntax:
set rrange [{<rmin> : <rmax>}]where <rmin> and <rmax> terms are constants or expressions.
Both the <rmin> and <rmax> terms are optional. Anything omitted will
not be changed, soset rrange [:10]changes rmax to 10 without affecting rmin.
samples
set samples <samples_1> {,<samples_2>}
show samplesWhen a 2-d plot is being done, only the value of <samples_1> is
relevant.When a surface plot is being done without the removal of hidden
lines, the value of samples specifies the number of samples that are
evaluated per iso line. Each iso-v line will have <sample_1> samples
and each iso-u line will have <sample_2> samples. If you only specify
<samples_1>, <samples_2> will be set to the same value as <samples_1>.
See also set isosamples.
size
set size {<xscale>,<yscale>}
show sizeTo set the size to normal size use:
set sizeTo make the plot half size use:
set size 0.5,0.5To make a landscape plot have a 1:1 aspect ratio in polar mode use:
set size 0.721,1.0show size
style
Plots may be displayed in one of thirteen styles: lines, points,
linespoints, impulses, dots, steps, fsteps, {x,y,xy}errorbars,
boxes, boxerrorbars, or boxxyerrorbars.
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
(or from the grid base for splot) to each point. The dots style
plots a tiny dot at each point; this is useful for
scatter plots with many points.The errorbars (or yerrorbars), xerrorbars, xyerrorbars styles are only
relevant to 2-d data file plotting. It
is treated like points for splots and function plots. For data
plots, errorbars is like points, except that a vertical or
horizontal error bar is also drawn: for each point (x,y), a line is
drawn from (x,ylow) to (x,yhigh) or (xlow,y) to (xhigh,y). A tic mark is
placed at the ends of the error bar. The (ylow, yhigh) or (xlow,xhigh)
values are read from the data file's columns, as specified with the using
option to plot. See plot errorbars for more information.The boxes style is only relevant to 2-d plotting. It draws
a box centred about the given x coordinate from the yaxis to the given
y coordinate. The width of the box is obtained in one of three
ways. If a data file has a third column, this will be used to set
the width of the box. Otherwise, if a width has been set using the
set boxwidth command, this will be used. Otherwise the width of each
box will be calculated automatically so that it touches the adjacent
boxes. Another style called boxerrorbars is also available and is
only relevant to 2-d data file plotting. This style is a combination
of the boxes and errorbars styles. The boxwidth will come from the fourth
column if the y errors are in the form of "ydelta" and the boxwidth was not
previously set equal to -2.0 (set boxwidth -2.0) or from the fifth
column if the y errors are in the form of "ylow yhigh". The boxwidth = -2.0 is
for the special case of 4-column data and the y errors are in the form of
"ylow yhigh". The boxwidth will be calculated auto
