\input{titlepage}
\section{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. Each file is loaded with the {\bf 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 ($\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 {\bf 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.
\section{Cd}
The {\bf cd} command changes working directory.

Syntax:
\begin{verbatim}
        cd <directory-name>
\end{verbatim}

The directory name must be enclosed in quotes.

Examples:

\begin{verbatim}
        cd 'subdir'
        cd ".."
\end{verbatim}
\section{Clear}
The {\bf clear} command erases the current screen or output device as
specified by {\bf set output}.  This usually generates a formfeed on
hardcopy devices.  Use {\bf set terminal} to set the device type. 
\section{Comment}
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.
\section{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 {\bf shell} command.

On MS-DOS, COMSPEC is used for the {\bf shell} command. 
\section{Exit}
The commands {\bf exit} and {\bf quit} and your computer's END-OF-FILE character
will exit GNUPLOT.  All these commands will clear the output device
(as the {\bf clear} command does) before exiting. 
\section{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 \{$<$real$>$,$<$imag$>$\}, where $<$real$>$
and $<$imag$>$ must be numerical constants.  For example \{3,2\}
represents 3 + 2i; \{0,1\} represents {\bf i} itself. The curly braces 
are explicitly required here. 
\subsection{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 {\bf sgn}
function is also supported, as in BASIC. 

\begin{center}
\begin{tabular}{|ccl|} \hline
Function & Arguments & Returns \\ \hline
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}}}$ \\
acos(x) & any  & $\cos^{-1} x$ (inverse cosine) in radians \\
arg(x) & complex & the phase of $x$ in radians\\
asin(x) & any  & $\sin^{-1} x$ (inverse sin) in radians \\
atan(x) & any  & $\tan^{-1} x$ (inverse tangent) in radians \\
besj0(x) & radians &  $j_{0}$ Bessel function of $x$ \\
besj1(x) & radians & $j_{1}$ Bessel function of $x$ \\
besy0(x) & radians & $y_{0}$ Bessel function of $x$ \\
besy1(x) & radians & $y_{1}$ Bessel function of $x$ \\
ceil(x) & any & $\lceil x \rceil$, smallest integer not less than $x$
(real part) \\
cos(x) & radians & $\cos x$, cosine of $x$ \\
cosh(x) & radians & $\cosh x$, hyperbolic cosine of $x$ \\
exp(x) & any & $e^{x}$,  exponential function of $x$ \\
floor(x) & any & $\lfloor x \rfloor$,  largest integer not greater
than $x$ (real part) \\
imag(x) & complex &  imaginary part of $x$ as a real number \\
int(x) & real &  integer part of $x$, truncated toward zero \\
log(x) & any & $\log_{e} x$,  natural logarithm (base $e$) of $x$ \\
log10(x) & any & $\log_{10} x$,  logarithm (base $10$) of $x$ \\
real(x) & any &  real part of $x$ \\
sgn(x) & any & 1 if $x>0$, -1 if $x<0$, 0 if $x=0$. imag($x$) ignored \\
sin(x) & radians & $\sin x$, sine of $x$ \\
sinh(x) & radians & $\sinh x$, hyperbolic sine $x$ \\
sqrt(x) & any & $\sqrt{x}$,  square root of $x$ \\
tan(x) & radians & $\tan x$,  tangent of $x$ \\
tanh(x) & radians & $\tanh x$, hyperbolic tangent of $x$\\
\hline
\end{tabular}
\end{center}
\subsection{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.
\subsubsection{Binary}
The following is a list of all the binary operators and their
usages:


\begin{center}
\begin{tabular}{|ccl|} \hline
\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\\
\hline
\end{tabular}
\end{center}
(*) 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. 
\subsubsection{Unary}
The following is a list of all the unary operators and their
usages:


\begin{center}
\begin{tabular}{|ccl|} \hline
\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 \\
\hline
\end{tabular}
\end{center}
(*) Starred explanations indicate that the operator requires an
integer argument.

The factorial operator returns a real number to allow a greater range.
\section{Help}
The {\bf help} command displays on-line help.  To specify information on a
particular topic use the syntax:

\begin{verbatim}
    help <topic> 
\end{verbatim}

If $<$topic$>$ 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.
\section{Load}
The {\bf load} command executes each line of the specified input file as
if it had been typed in interactively.  Files created by the {\bf save}
command can later be {\bf load}ed.  Any text file containing valid
commands can be created and then executed by the {\bf load} command.
Files being {\bf load}ed may themselves contain {\bf load} commands. See
{\bf comment} for information about comments in commands. 

The {\bf load} command must be the last command on the line. 

Syntax:
\begin{verbatim}
        load <input-file>
\end{verbatim}

The name of the input file must be enclosed in quotes.

Examples:

\begin{verbatim}
        load 'work.gnu'
        load "func.dat"
\end{verbatim}
The {\bf 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. 
\section{Pause}
Pause is useful in conjunction with {\bf load} files.  The command {\bf pause}
displays any text associated with the command and then waits the
specified amount of time.  This allows one to build a {\bf 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:
\begin{verbatim}
        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."
\end{verbatim}

Syntax:
\begin{verbatim}
        pause <expression> {"string"}
\end{verbatim}
Note the string is optional, and if present must be enclosed in quotes.
\section{Plot}
{\bf plot} is the primary command of the program.  It plots functions and
data in many, many ways.  The full syntax of this command is:

\begin{verbatim}
  plot {ranges}  <function> {title} {style} {, <function> {title} {style}...}
\end{verbatim}

Where $<$function$>$ is either a mathematical expression or the name of a
data file enclosed in quotes.  User-defined functions and variables
may also be defined here. 

Curly braces \{,\} denote optional items.

A {\bf plot} command can be as simple as

\begin{verbatim}
 plot sin(x)
\end{verbatim}

or as complex as (!)

\begin{verbatim}
 plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
\end{verbatim}
\subsection{Data-file}
Discrete data contained in a file can displayed by specifying the
name of the data file (enclosed in quotes) on the {\bf 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.  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 {\bf lines} or {\bf linespoints} (see {\bf 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:

\begin{verbatim}
        pop(x) = 103*exp((1965-x)/10)
        plot [1960:1990] 'population.dat', pop(x)
\end{verbatim}

The file population.dat might contain:

\begin{verbatim}
 # Gnu population in Antarctica since 1965
 1965   103
 1970   55
 1975   34
 1980   24
 1985   10
\end{verbatim}
\subsection{Ranges}
The optional range specifies the region of the plot which will be displayed. 

Ranges may be provided on the {\bf plot} command line and affect only
that plot, or in the {\bf set xrange} and {\bf set yrange} commands, to
change the default ranges for future plots.

Syntax:
\begin{verbatim}
        [{dummy-var =} {xmin : xmax}] { [{ymin : ymax}] }
\end{verbatim}

Where dummy-var is the independent variable (the default is {\bf x},
but this may be changed with the {\bf 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 {\bf plot} command line turns autoscaling for
that axis OFF for that plot. Using one of the {\bf set} range commands
turns autoscaling off for that axis for future plots, unless changed
later. (See {\bf set autoscale}).


Examples:

This uses current ranges:
\begin{verbatim}
        plot cos(x)
\end{verbatim}

This sets the xrange only:
\begin{verbatim}
        plot [-10:30] sin(pi*x)/(pi*x)
\end{verbatim}

This is the same, but uses t as the dummy-variable:
\begin{verbatim}
        plot [t = -10 :30]  sin(pi*t)/(pi*t)
\end{verbatim}

This sets both the x and yranges:
\begin{verbatim}
        plot [-pi:pi] [-3:3]  tan(x), 1/x
\end{verbatim}

This sets only the yrange:
\begin{verbatim}
        plot [] [-2:sin(5)*-8] sin(x)**besj0(x)
\end{verbatim}

This sets xmax and ymin only:
\begin{verbatim}
        plot [:200] [-pi:]  exp(sin(x))
\end{verbatim}
\subsection{Style}
Plots may be displayed in one of four styles: {\bf lines}, {\bf points},
{\bf linespoints}, {\bf impulses}, or {\bf dots}.  The {\bf lines} style connects
adjacent points with lines. The {\bf points} style displays a small
symbol at each point.  The {\bf linespoints} style does both {\bf lines} and
{\bf points}. The {\bf impulses} style displays a vertical line from the X
axis to each point. The {\bf dots} style plots a tiny dot at each point;
this is useful for scatter plots with many points.

Default styles are chosen with the {\bf set function style} and
{\bf 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:

\begin{verbatim}
        with <style> {<linetype> {<pointtype>}}
\end{verbatim}

Where $<$style$>$ is either {\bf lines}, {\bf points}, {\bf linespoints}, {\bf impulses},
or {\bf dots}. These keywords may be abbreviated. 
Curly braces denote optional items.  The $<$linetype$>$ and $<$pointtype$>$ 
are positive integers, 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:
\begin{verbatim}
        plot sin(x) with impulses
\end{verbatim}

This plots sin(x) with points, cos(x) default:
\begin{verbatim}
        plot [-9:30]  sin(x) w points, cos(x)
\end{verbatim}

This plots tan(x) with the default function style, ``data.1'' with lines:
\begin{verbatim}
        plot [] [-2:5] tan(x), "data.1" with l
\end{verbatim}

This plots ``leastsq.dat'' with impulses:
\begin{verbatim}
        plot 'leastsq.dat' w i
\end{verbatim}

This plots sin(x) and cos(x) with the same line type:
\begin{verbatim}
        plot sin(x) with line 1, cos(x) with line 1
\end{verbatim}

This plots sin(x) and cos(x) with linespoints, using the
same line type but different point types:
\begin{verbatim}
        plot sin(x) with linesp 1 3, cos(x) with linesp 1 4
\end{verbatim}
This plots file ``data'' with points style 3:
\begin{verbatim}
        plot "data" with points 1 3 
\end{verbatim}
Note that the line style must be specified in order to specify 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.
\subsection{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 {\bf title} option. This option 
should precede any {\bf with} option.

Syntax:
\begin{verbatim}
        title <title>
\end{verbatim}

Where $<$title$>$ is the new title of the plot and must be enclosed in
quotes.

Examples:

This plots y=x with the title 'x':
\begin{verbatim}
        plot x
\end{verbatim}

This plots y=x with the title 'y=x':
\begin{verbatim}
        plot x title 'y=x'
\end{verbatim}

This plots x squared with title 'x\verb+^+2' and ``data.1'' with title 'measured data':
\begin{verbatim}
        plot x**2 title "x^2", "data.1" t 'measured data'
\end{verbatim}
\section{Print}
The {\bf print} command prints the value of $<$expression$>$ to the screen.

Syntax:
\begin{verbatim}
        print <expression>
\end{verbatim}

See {\bf expressions}.
\section{Pwd}
The {\bf pwd} command prints the name of the working directory to the screen.

Syntax:
\begin{verbatim}
        pwd
\end{verbatim}
\section{Quit}
The {\bf exit} and {\bf quit} commands and your computer's END-OF-FILE
character will exit GNUPLOT.  All these commands will clear the
output device (as the {\bf clear} command does) before exiting. 
\section{Replot}
The {\bf replot} command without arguments repeats the last {\bf plot} command.  
This can be useful for viewing a plot with different {\bf set} options, 
or when generating the same plot for several devices.

Arguments specified after a {\bf replot} command will be added onto the last
{\bf plot} command (with an implied ',' separator) before it is repeated.
{\bf replot} accepts the same arguments as the {\bf plot} command except that
ranges cannot be specified. 
\section{Save}
The {\bf save} command saves user-defined functions, variables, set
options or all three plus the last plot command to the specified file. 

Syntax:
\begin{verbatim}
        save  {<option>} <filename>
\end{verbatim}

Where $<$option$>$ is {\bf functions}, {\bf variables} or {\bf set}.  If no option is
used GNUPLOT saves functions, variables, set options and the last plot
command. 

{\bf save}d files are written in text format and may be read by the {\bf load}
command.

The filename must be enclosed in quotes.

Examples:

\begin{verbatim}
        save "work.gnu"
        save functions 'func.dat'
        save var 'var.dat'
        save set "options.dat"
\end{verbatim}
\section{Set-show}
The {\bf set} command sets LOTS of options.

The {\bf show} command shows their settings.  {\bf show all} shows all the
settings. 
\subsection{Arrow}
Arbitrary arrows can be placed on the plot using the {\bf set arrow}
command.

Syntax:

\begin{verbatim}
         set arrow {tag} {from sx,sy} {to ex,ey}
         set noarrow {tag}
         show arrow
\end{verbatim}


Curly braces \{\} denote optional items.
All positions x,y default to 0,0.
The x and y values are in the graph's coordinate system.  
The tag is an integer that is used to identify 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 {\bf set
arrow} command with the appropriate tag, and specify the parts of the
arrow to be changed. 
Arrows outside the plotted boundaries are permitted but may cause
device errors; use at your own risk.

Examples: 

To set an arrow pointing from the origin to (1,2) use
\begin{verbatim}
         set arrow to 1,2
\end{verbatim}
To set an arrow from (-10,4) to (-5,5), and tag the arrow number 3, use:
\begin{verbatim}
         set arrow 3 from -10,4 to -5,5
\end{verbatim}
To change the preceding arrow begin at 1,1, use
\begin{verbatim}
         set arrow 3 from 1,1
\end{verbatim}
To delete arrow number 2 use:
\begin{verbatim}
         set noarrow 2
\end{verbatim}
To delete all arrows use:
\begin{verbatim}
         set noarrow
\end{verbatim}
To show all arrows (in tag order) use:
\begin{verbatim}
         show arrow
\end{verbatim}
\subsection{Autoscale}
Auto scaling may be set on the X and/or Y axis. The default is to
autoscale both axes.

If autoscaling of the Y axis is set, the Y axis is automatically scaled 
to fit the range of the function or data being plotted.  If autoscaling 
of the Y axis is not set, the current Y range is used.  See {\bf set yrange}. 

If autoscaling of the X axis is set, the X axis is automatically scaled
to fit the range of the data being plotted.  Autoscaling of the X axis 
will operate only on data.  Functions do not affect the X range and the
range used for functions is determined by the data plots.
See {\bf set xrange}.

Syntax:
\begin{verbatim}
        set autoscale <axes>
        set noautoscale <axes>
        show autoscale
\end{verbatim}

where $<$axes$>$ is either {\bf x}, {\bf y}, or {\bf xy}.
If $<$axes$>$ is not given then both axes are assumed.

Examples:

These set autoscaling of the Y axis.  X axis autoscaling not affected.
\begin{verbatim}
        set autoscale y
\end{verbatim}

This sets autoscaling of the X and Y axes.
\begin{verbatim}
        set autoscale xy
        set autoscale
\end{verbatim}

This disables autoscaling of the X and Y axes.
\begin{verbatim}
        set noautoscale
\end{verbatim}
This disables autoscaling of the X axis only.
\begin{verbatim}
        set noautoscale x
\end{verbatim}
\subsection{Clip}
GNUPLOT can 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).  To turn
on clipping, use {\bf set clip points}.  To turn it back off, use {\bf set
noclip points}. The default is {\bf noclip}.  Without clipping you may have
points near the boundaries that look bad; try adjusting the x and y ranges.

Syntax:
\begin{verbatim}
        set clip points
        set noclip points
\end{verbatim}
GNUPLOT can also clip lines that connect a point that is in range
with a point that is out of range. The default is to draw the 
in-range portion of such lines (i.e., to ``clip'' them). With the 
following syntax, the default is {\bf set clip one}. The alternative 
({\bf set noclip one}) is to not draw any portion of the line segment. In
no case is a line drawn outside the plotting area.

Syntax:
\begin{verbatim}
        set clip one
        set noclip one
\end{verbatim}
GNUPLOT does not show lines that are wholly out of range. Some lines
may have both endpoints out of range, but pass through the plotting
area. By default, GNUPLOT does not draw these lines ({\bf set noclip
two}). They may be drawn (and clipped) with {\bf set clip two}.
Syntax:
\begin{verbatim}
        set clip two
        set noclip two
\end{verbatim}
To check the state of all forms of clipping, use
\begin{verbatim}
        show clip
\end{verbatim}
The following forms are also permitted. These allow backward
compatibility with older versions. 
\begin{verbatim}
       set clip
       set noclip
\end{verbatim}
{\bf set clip} is synonymous with {\bf set clip points}. {\bf set noclip} turns
off all three types of clipping ({\bf points}, {\bf one}, and {\bf two}).
\subsection{Dummy}
By default, GNUPLOT assumes that the independent variable for 
the {\bf plot} command line is {\bf x}.  {\bf x} is called the dummy variable because
it is just a notation to indicate the independent variable.  The
{\bf set dummy} command changes this default dummy variable name.  For
example, you may find it more convenient to call the dummy variable
{\bf t} when plotting time functions:

\begin{verbatim}
        set dummy t
        plot sin(t), cos(t)
\end{verbatim}

Syntax:
\begin{verbatim}
        set dummy <dummy-var>
        show dummy
\end{verbatim}
\subsection{Format}
The format of the tic-mark labels can be set with the {\bf 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.

Syntax:
\begin{verbatim}
        set format {<axes>} {"format-string"}
        show format
\end{verbatim}

where $<$axes$>$ is either {\bf x}, {\bf y}, {\bf xy}, or nothing (which is the same
as {\bf 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 {\bf set noxtics} or {\bf set noytics}. 

See also {\bf set xtics} and {\bf set ytics} for more control over tic labels.
\subsection{Functions}
The {\bf show functions} command lists all user-defined functions and
their definitions. 

Syntax:
\begin{verbatim}
        show functions
\end{verbatim}
\subsection{Grid}
The optional {\bf set grid} draws a grid at the tic marks with the axis
linetype.

Syntax:
\begin{verbatim}
        set grid
        set nogrid
        show grid
\end{verbatim}
\subsection{Key}
The {\bf set key} enables a key describing curves on a plot.  
By default the key is placed in the upper right corner of
the plot.  

Syntax:
\begin{verbatim}
        set key
        set key x,y
        set nokey
        show key
\end{verbatim}

The coordinates x,y 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 {\bf plot} command.  The lines are vertically
arranged so an imaginary straight line divides the left- and 
right-hand sides of the key.  It is the x-coordinate of this
line that you specify with the optional x in the {\bf set key}
command; the y in the {\bf set key} command is top of the key.
Some or all of the key may be outside of the plot boundary, if you
wish, although this may interfere with other labels and may cause an
error on some devices. 

Examples:

This places the key at the default location:
\begin{verbatim}
        set key
\end{verbatim}
This disables the key.
\begin{verbatim}
        set nokey
\end{verbatim}
This places a key at coordinates 2,3.5
\begin{verbatim}
        set key 2,3.5
\end{verbatim}
\subsection{Label}
Arbitrary labels can be placed on the plot using the {\bf set label}
command.

Syntax:

\begin{verbatim}
         set label {tag} {"label_text"} {at x,y} {<justification>}
         set nolabel {tag}
         show label
\end{verbatim}


Curly braces \{\} denote optional items.
The text defaults to '''', and the position x,y to 0,0.
The x and y 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 {\bf 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 point x,y. If you
want to adjust the way the label is positioned with respect to the
point x,y, add the parameter $<$justification$>$, which may be {\bf left},
{\bf right} or {\bf center}, indicating that the point is to be at the left,
right or center of the text.  The $<$justification$>$ may be abbreviated.
Labels outside the plotted boundaries are permitted but may interfere
with axes labels or other text; use at your own risk.

Examples: 

To set a label at (1,2) to ``y=x'' use:
\begin{verbatim}
         set label "y=x" at 1,2
\end{verbatim}
To set a label ``y=x\verb+^+2'' with the right of the text at (2,3), and tag
the label number 3, use:
\begin{verbatim}
         set label 3 "y=x^2" at 2,3 right
\end{verbatim}
To change the preceding label to center justification, use:
\begin{verbatim}
         set label 3 center
\end{verbatim}
To delete label number 2 use:
\begin{verbatim}
         set nolabel 2
\end{verbatim}
To delete all labels use:
\begin{verbatim}
         set nolabel
\end{verbatim}
To show all labels (in tag order) use:
\begin{verbatim}
         show label
\end{verbatim}
The Imagen driver allows $\backslash$$\backslash$ in a string to specify a newline.
\subsection{Logscale}
Log scaling may be set on the X and/or Y axis.

Syntax:
\begin{verbatim}
        set logscale <axes>
        set nologscale <axes>
        show logscale
\end{verbatim}

Where $<$axes$>$ is either {\bf x}, {\bf y}, or {\bf xy}.
If $<$axes$>$ is not given then both axes are assumed.
The command {\bf set logscale} turns on log scaling on the specified
axes, while {\bf set nologscale} turns off log scaling.
\subsection{Offsets}
The amount of the graph that the plot takes up may be controlled
to some extent with the {\bf set offsets} command.  This command takes
four offset arguments -- $<$left$>$, $<$right$>$, $<$top$>$ and $<$bottom$>$.  
By default, each offset is 0.  Each offest 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.

Syntax:
\begin{verbatim}
        set offsets <left>, <right>, <top>, <bottom>
        show offsets
\end{verbatim}
\subsection{Output}
By default, plots are displayed to the standard output.  The
{\bf set output} command redirects the display to the specified file or
device. 

Syntax:
\begin{verbatim}
        set output {<filename>}
        show output
\end{verbatim}

The filename must be enclosed in quotes.  If the filename is
omitted, output will be sent to the standard output. 
\subsection{Polar}
The {\bf 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].

The command {\bf 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].

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 on a rectangular
grid, and the {\bf x} and {\bf y} axes are both in units of the radius. Thus,
the yrange controls both dimensions of the plot output. There is no
way to specify the output dimensions separately.

Syntax:
\begin{verbatim}
        set polar
        set nopolar
        show polar
\end{verbatim}
Example:
\begin{verbatim}
        set polar
        plot x*sin(x)
        plot [-2*pi:2*pi] [-3:3] x*sin(x)
\end{verbatim}
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].
\subsection{Samples}
The sampling rate of functions may be changed by the {\bf set samples}
command.  By default, sampling is set to 160 points.  A higher
sampling rate will produce more accurate plots, but will take
longer.  When plotting datafiles, the sampling rate must be set 
higher than the number of data points.

Syntax:
\begin{verbatim}
        set samples <expression>
        show samples
\end{verbatim}
\subsection{Size}
The {\bf set size} command scales the displayed size of the plot.
On some terminals, changing the size of the plot will result in
text being misplaced.  Increasing the size of the plot may 
produce strange results.  Decreasing is safer.

Syntax:

\begin{verbatim}
        set size {x,y}
        show size
\end{verbatim}

The x and y values are the scaling factors for the size.
The defaults (1,1) are selected if the scaling factors are omitted.

Examples: 

To set the size to normal size use:
\begin{verbatim}
        set size
\end{verbatim}
To make the plot half size use:
\begin{verbatim}
        set size 0.5,0.5
\end{verbatim}
To show the size use:
\begin{verbatim}
        show size
\end{verbatim}
For the LaTeX and Fig terminals the default size (scale factor 1,1)
is 5 inches wide by 3 inches high. Note that the size of the plot
includes the space used by the labels; the plotting area itself is
smaller. 
\subsection{Style}
Plots may be displayed in one of five styles: {\bf lines}, {\bf points},
{\bf linespoints}, {\bf impulses}, or {\bf dots}.  The {\bf lines} style connects
adjacent points with lines. The {\bf points} style displays a small
symbol at each point.  The {\bf linespoints} style does both {\bf lines} and
{\bf points}. The {\bf impulses} style displays a vertical line from the X
axis to each point. The {\bf dots} style plots a tiny dot at each data
point; this is useful for scatter plots with many points.

Default styles are chosen with the {\bf set function style} and {\bf set
data style} commands.  See {\bf plot style} for information about how 
to override the default plotting style for individual functions. 

Syntax:
\begin{verbatim}
        set function style <style>
        set data style <style>
        show function style
        show data style
\end{verbatim}

Where $<$style$>$ is either {\bf lines}, {\bf points}, {\bf linespoints}, {\bf impulses},
or {\bf dots}.
\subsection{Terminal}
GNUPLOT supports many different graphics devices.  Use the {\bf set
terminal} command to select the type of device for which GNUPLOT
will produce output. 

Syntax:
\begin{verbatim}
        set terminal {<terminal-type>}
        show terminal
\end{verbatim}

If $<$terminal-type$>$ is omitted, GNUPLOT will list the available
terminal types.  $<$terminal-type$>$ may be abbreviated. 

Use {\bf set output} to redirect this output to a file or device.
\subsection{Tics}
By default, tics are drawn inwards from the border on all four sides.
The {\bf set tics} command can be used to change the tics to be 
drawn outwards on the left and bottom borders only.  
This is useful when doing impulse plots.

Syntax:
\begin{verbatim}
        set tics {<direction>}
        show tics
\end{verbatim}

Where $<$direction$>$ may be {\bf in}, {\bf out} or nothing (which is the same as in).

See also the {\bf set xtics} and {\bf set ytics} command for more control of
tic marks. 
\subsection{Title}
The {\bf set title} command sets the title which will be centered
at the top of the plot.

Syntax: 
\begin{verbatim}
         set title 
         set title "title-text"
         show title
\end{verbatim}

The first clears the title (default).
The second form sets the title to ``title-text'' (without the quotes).
The Imagen driver allows $\backslash$$\backslash$ in a string to specify a newline.
\subsection{Variables}
The {\bf show variables} command lists all user-defined variables and
their values. 

Syntax:
\begin{verbatim}
        show variables
\end{verbatim}
\subsection{Xlabel}
The {\bf set xlabel} command sets the x-axis label which will be centered
at the bottom of the plot.

Syntax: 
\begin{verbatim}
         set xlabel 
         set xlabel "label"
         show xlabel
\end{verbatim}

The first clears the x-axis label (default).
The second form sets the x-axis label to ``label'' (without the quotes).
The Imagen driver allows $\backslash$$\backslash$ in a string to specify a newline.
\subsection{Xrange}
The {\bf set xrange} command sets the horizontal range which will be
displayed.  This command turns X axis autoscaling OFF.

This range may also be specified on the {\bf plot} command line.

Syntax:
\begin{verbatim}
        set xrange [{<xmin> : <xmax>}]
\end{verbatim}

Where $<$xmin$>$ and $<$xmax$>$ terms are expressions or constants.

Both the $<$xmin$>$ and $<$xmax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set xrange [:10]
\end{verbatim}
changes xmax to 10 without affecting xmin. 
\subsection{Xtics}
Very fine control of the {\bf x} axes tic marks is possible with the {\bf set
xtics} and {\bf set noxtics} command. The x-axis tic marks may be turned
off with the {\bf set noxtics} command. They may be turned on (the
default state) with {\bf set xtics}.
If you prefer your own series of tic marks, you may use the form
\begin{verbatim}
         set xtics <start>, <incr>{, <end>}
\end{verbatim}
The curly braces indicate that the $<$end$>$ parameter is optional. 
This command specifies that a series of tics will be plotted on the
{\bf x} axis between the {\bf x} values $<$start$>$ and $<$end$>$ with an increment
of $<$incr$>$. If $<$end$>$ is not given it is assumed to be infinity. The
increment may be negative. Example:
\begin{verbatim}
          set xtics 0,.5,10
\end{verbatim}
makes tics 0, 0.5, 1, 1.5, ..., 9.5, 10.
If you need arbitrary tic positions, or non-numeric tic labels, 
any non-empty set of tic positions and labels may be given with this
format:
\begin{verbatim}
         set xtics ({"label"} pos {, {"label"} pos}...)
\end{verbatim}
Again curly braces contain optional components. Thus, a set of tics
are a set of positions, each with its own optional label. Note that
the label is a string enclosed by quotes, and may be a constant
string, such as ``hello'', or contain formatting information for the tic
number (which is the same as the position), such as ''\%3f clients''.
See {\bf set format} for more information about this case. The label may 
even be empty. Examples:
\begin{verbatim}
         set xtics ("low" 0, "medium" 50, "high" 100)
         set xtics (1,2,4,8,16,32,64,128,256,512,1024)
         set xtics ("bottom" 0, "" 10, "top" 20)
\end{verbatim}
Tics will only be plotted when in range.
The {\bf set ytics} and {\bf set noytics} commands work identically.
See also {\bf set format} command.
\subsection{Ylabel}
The {\bf set ylabel} command sets the y-axis label.
The position of this label depends on the terminal, and can be
one of the following three positions.

1. Horizontal text flushed left at the top left of the plot.  
Terminals that cannot rotate text will probably use this method.

2. Vertical text centered vertically at the left of the plot.
Terminals that can rotate text will probably use this method.

3. Horizontal text centered vertically at the left of the plot.
The Latex and EEPIC drivers use this method.  The user must insert 
line breaks using $\backslash$$\backslash$ to prevent the ylabel from overwriting
the plot.  To produce a vertical row of characters, add $\backslash$$\backslash$
between every printing character.

Syntax:  
\begin{verbatim}
         set ylabel 
         set ylabel "label"
         show ylabel
\end{verbatim}

The first clears the y-axis label (default).
The second form sets the y-axis label to ``label'' (without the quotes).

The Latex, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline. 
\subsection{Yrange}
The {\bf set yrange} command sets the vertical range which will be
displayed.  This command turns Y axis autoscaling OFF. 

This range may also be specified on the {\bf plot} command line.

Syntax:
\begin{verbatim}
        set yrange [{<ymin> : <ymax>}]
\end{verbatim}

Where $<$ymin$>$ and $<$ymax$>$ terms are expressions or constants.

Both the $<$ymin$>$ and $<$ymax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set yrange [:10]
\end{verbatim}
changes ymax to 10 without affecting ymin. 
\subsection{Ytics}
The {\bf set ytics} and {\bf set noytics} commands are similar to the {\bf set xtics}
and {\bf set noxtics} commands. Please see {\bf set xtics}.
\subsection{Zero}
GNUPLOT will not plot a point if its imaginary part is greater in
magnitude than the {\bf zero} threshold.  The default {\bf zero} value is
1e-8. This can be changed with the {\bf set zero} command.

Syntax:
\begin{verbatim}
        set zero <expression>
        show zero
\end{verbatim}
\section{Shell}
The {\bf shell} command spawns an interactive shell.  To return to
GNUPLOT, type {\bf logout} if using VMS, {\bf exit} or your END-OF-FILE
character if using Unix, or {\bf exit} if using MS-DOS. 

A single shell command may be spawned by preceding it with the !
character (\$ if using VMS) at the beginning of a command line.
Control will return immediately to GNUPLOT after this command is
executed.  For example,

\begin{verbatim}
     ! dir
\end{verbatim}

prints a directory listing and then returns to GNUPLOT.
\section{Start-up}
When GNUPLOT is run, it looks for an initialization file to load. 
This file is called {\bf .gnuplot} on Unix systems, and {\bf GNUPLOT.INI} on
other systems.  If this file is not found in the current directory,
the program will look for it in your home directory (under MS-DOS, the
environment variable GNUPLOT should contain the name of this
directory). 

If this file is found, GNUPLOT executes the commands in this file.
This is most useful for setting your terminal type and defining any
functions or variables which you use often.  The variable {\bf pi} is
already defined for you. 
\section{Substitution}
Command-line substitution is specified by a system command enclosed in
backquotes.  This command is spawned and the output it produces
replaces the name of the command (and backquotes) on the command line.

Newlines in the output produced by the spawned command are replaced with
blanks.

Command-line substitution can be used anywhere on the GNUPLOT command
line. 


Example:

This will run the program {\bf leastsq} and substitute {\bf leastsq}
(including quotes) on the command line with its output:

\begin{verbatim}
 f(x) = `leastsq`
\end{verbatim}

or, in VMS

\begin{verbatim}
 f(x) = `run leastsq`
\end{verbatim}
\section{User-defined}
You may define your own functions and variables.  User-defined
functions and variables may be used anywhere. 

User-defined function syntax:
\begin{verbatim}
    <function-name> ( <dummy-var> ) =  <expression>
\end{verbatim}

Where $<$expression$>$ is defined in terms of $<$dummy-var$>$.

User-defined variable syntax:
\begin{verbatim}
    <variable-name> = <constant-expression>
\end{verbatim}

Examples:
\begin{verbatim}
    w = 2
    q = floor(tan(pi/2 - 0.1))
    f(x) = sin(w*x)
    sinc(x) = sin(pi*x)/(pi*x)
    delta(t) = (t == 0)
    ramp(t) = (t > 0) ? t : 0
\end{verbatim}

The variable {\bf pi} is already defined for you.

See {\bf show functions} and {\bf show variables}.
\section{Bugs}
The atan() function does not work correctly for complex arguments.

The bessel functions do not work for complex arguments.

The most important known bug is actually in the stdio library for the
Sun4 operating system (SunOS Sys4-3.2). The ''\%g'' format for {\bf printf}
sometimes incorrectly prints numbers (e.g., 200000.0 as ``2'').  Thus,
tic mark labels may be incorrect on a Sun4 version of gnuplot.  You
may work around it by rescaling your data or by using the {\bf set format}
command to change the tic mark format to ''\%7.0f'' or some other
appropriate format. This appears to have been fixed in SunOS 4.0.

Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
and SunOS 4.0, the {\bf sscanf} routine incorrectly parses ``00 12'' with
the format ''\%f \%f'' and reads 0 and 0 instead of 0 and 12.  This
affects data input. If your data file contains X coordinates that are
zero but are specified like '00', '000', etc, then you will read the
wrong Y values. Check your data files or do not use a Sun4 until they
fix the bug. It does NOT appear that this has been fixed in SunOS 4.0.

Microsoft C 5.1 has a nasty bug associated with the \%g format for
printf.  When any of the formats ''\%.2g'', ''\%.1g'', ''\%.0g'', ''\%.g'' are
used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.  
Numbers that should be printed in the \%e format are incorrectly 
printed in the \%f format, with the wrong number of zeros after the 
decimal point.
To work around this problem, use the \%e or \%f formats explicitly.

Gnuplot when compiled with Microsoft C did not work correctly on two
VGA displays that were tested.  The CGA, EGA and VGA drivers should 
probably be rewritten to use the Microsoft C graphics library.
Gnuplot compiled with Turbo C uses the Turbo C graphics drivers and 
does work correctly with VGA displays. 

VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented \%g 
format for printf.  The numbers are printed numerically correct, but 
may not be in the requested format.  The K\&R second edition says that 
for the \%g format, \%e is used if the exponent is less than -4 or greater 
than or equal to the precision.  The VAX uses \%e format if the exponent 
is less than -1.  The VAX appears to take no notice of the precision 
when deciding whether to use \%e or \%f for numbers less than 1.
To work around this problem, use the \%e or \%f formats explicitly.
From the VAX C 2.4 release notes:
e,E,f,F,g,G  Result will always contain  a  decimal  point.
For g and G, trailing zeros will not be removed from the result.

VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
\%g format than release 2.4, but not much.  Trailing decimal points are 
now removed, but trailing zeros are still not removed from \%g numbers 
in exponential format.

Please report any bugs you find to pixar!bug-gnuplot@sun.com or
pixar!bug-gnuplot@ucbvax.berkeley.edu.
\end{document}
