@c DO NOT EDIT!  Generated automatically by munge-texi.

@c Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005,
@c               2006, 2007, 2008 John W. Eaton
@c
@c This file is part of Octave.
@c
@c Octave is free software; you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by the
@c Free Software Foundation; either version 3 of the License, or (at
@c your option) any later version.
@c 
@c Octave is distributed in the hope that it will be useful, but WITHOUT
@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@c for more details.
@c 
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <http://www.gnu.org/licenses/>.

@node Plotting
@chapter Plotting
@cindex plotting
@cindex graphics

@menu
* Plotting Basics::             
* Advanced Plotting::           
@end menu

@node Plotting Basics
@section Plotting Basics

Octave makes it easy to create many different types of two- and
three-dimensional plots using a few high-level functions.

If you need finer control over graphics, see @ref{Advanced Plotting}.

@menu
* Two-Dimensional Plots::       
* Three-Dimensional Plotting::  
* Plot Annotations::            
* Multiple Plots on One Page::  
* Multiple Plot Windows::       
* Printing Plots::              
* Test Plotting Functions::     
@end menu

@node Two-Dimensional Plots
@subsection Two-Dimensional Plots

The @code{plot} function allows you to create simple x-y plots with
linear axes.  For example,

@example
@group
x = -10:0.1:10;
plot (x, sin (x));
@end group
@end example

@noindent
displays a sine wave shown in @ref{fig:plot}.  On most systems, this
command will open a separate plot window to display the graph.

@float Figure,fig:plot
@image{plot,8cm}
@caption{Simple Two-Dimensional Plot.}
@end float

The function @code{fplot} also generates two-dimensional plots with
linear axes using a function name and limits for the range of the
x-coordinate instead of the x and y data.  For example,

@example
@group
fplot (@@sin, [-10, 10], 201);
@end group
@end example

@noindent
produces a plot that is equivalent to the one above, but also includes a
legend displaying the name of the plotted function.

@anchor{doc-plot}
@deftypefn {Function File} {} plot (@var{y})
@deftypefnx {Function File} {} plot (@var{x}, @var{y})
@deftypefnx {Function File} {} plot (@var{x}, @var{y}, @var{property}, @var{value}, @dots{})
@deftypefnx {Function File} {} plot (@var{x}, @var{y}, @var{fmt})
@deftypefnx {Function File} {} plot (@var{h}, @dots{})
Produces two-dimensional plots.  Many different combinations of
arguments are possible.  The simplest form is

@example
plot (@var{y})
@end example

@noindent
where the argument is taken as the set of @var{y} coordinates and the
@var{x} coordinates are taken to be the indices of the elements,
starting with 1.

To save a plot, in one of several image formats such as PostScript
or PNG, use the @code{print} command.

If more than one argument is given, they are interpreted as

@example
plot (@var{y}, @var{property}, @var{value}, @dots{})
@end example

@noindent
or

@example
plot (@var{x}, @var{y}, @var{property}, @var{value}, @dots{})
@end example

@noindent
or

@example
plot (@var{x}, @var{y}, @var{fmt}, @dots{})
@end example

@noindent
and so on.  Any number of argument sets may appear.  The @var{x} and
@var{y} values are interpreted as follows:

@itemize @bullet
@item
If a single data argument is supplied, it is taken as the set of @var{y}
coordinates and the @var{x} coordinates are taken to be the indices of
the elements, starting with 1.

@item
If the @var{x} is a vector and @var{y} is a matrix, then
the columns (or rows) of @var{y} are plotted versus @var{x}.
(using whichever combination matches, with columns tried first.)

@item
If the @var{x} is a matrix and @var{y} is a vector,
@var{y} is plotted versus the columns (or rows) of @var{x}.
(using whichever combination matches, with columns tried first.)

@item
If both arguments are vectors, the elements of @var{y} are plotted versus
the elements of @var{x}.

@item
If both arguments are matrices, the columns of @var{y} are plotted
versus the columns of @var{x}.  In this case, both matrices must have
the same number of rows and columns and no attempt is made to transpose
the arguments to make the number of rows match.

If both arguments are scalars, a single point is plotted.
@end itemize

Multiple property-value pairs may be specified, but they must appear
in pairs.  These arguments are applied to the lines drawn by
@code{plot}.

If the @var{fmt} argument is supplied, it is interpreted as
follows.  If @var{fmt} is missing, the default gnuplot line style
is assumed.

@table @samp
@item -
Set lines plot style (default).

@item .
Set dots plot style.

@item L
Set steps plot style.

@item @var{n}
Interpreted as the plot color if @var{n} is an integer in the range 1 to
6.

@item @var{nm}
If @var{nm} is a two digit integer and @var{m} is an integer in the
range 1 to 6, @var{m} is interpreted as the point style.  This is only
valid in combination with the @code{@@} or @code{-@@} specifiers.

@item @var{c}
If @var{c} is one of @code{"k"} (black), @code{"r"} (red), @code{"g"}
(green), @code{"b"} (blue), @code{"m"} (magenta), @code{"c"} (cyan),
or @code{"w"} (white), it is interpreted as the line plot color.

@item ";title;"
Here @code{"title"} is the label for the key.

@item +
@itemx *
@itemx o
@itemx x
@itemx ^
Used in combination with the points or linespoints styles, set the point
style.
@end table

The @var{fmt} argument may also be used to assign key titles.
To do so, include the desired title between semi-colons after the
formatting sequence described above, e.g. "+3;Key Title;"
Note that the last semi-colon is required and will generate an error if
it is left out.

Here are some plot examples:

@example
plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+")
@end example

This command will plot @code{y} with points of type 2 (displayed as
@samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of
color 4 (magenta) and @code{y4} with points displayed as @samp{+}.

@example
plot (b, "*", "markersize", 3)
@end example

This command will plot the data in the variable @code{b},
with points displayed as @samp{*} with a marker size of 3.

@example
t = 0:0.1:6.3;
plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);");
@end example

This will plot the cosine and sine functions and label them accordingly
in the key.

If the first argument is an axis handle, then plot into these axes, 
rather than the current axis handle returned by @code{gca}. 
@seealso{semilogx, semilogy, loglog, polar, mesh, contour, bar,
stairs, errorbar, xlabel, ylabel, title, print}
@end deftypefn


@anchor{doc-fplot}
@deftypefn {Function File} {} fplot (@var{fn}, @var{limits})
@deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{tol})
@deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{n})
@deftypefnx {Function File} {} fplot (@dots{}, @var{fmt})
Plot a function @var{fn}, within the defined limits.  @var{fn}
an be either a string, a function handle or an inline function.
The limits of the plot are given by @var{limits} of the form
@code{[@var{xlo}, @var{xhi}]} or @code{[@var{xlo}, @var{xhi},
@var{ylo}, @var{yhi}]}. @var{tol} is the default tolerance to use for the
plot, and if @var{tol} is an integer it is assumed that it defines the 
number points to use in the plot.  The @var{fmt} argument is passed
to the plot command.

@example
   fplot ("cos", [0, 2*pi])
   fplot ("[cos(x), sin(x)]", [0, 2*pi])
@end example
@seealso{plot}
@end deftypefn


The functions @code{semilogx}, @code{semilogy}, and @code{loglog} are
similar to the @code{plot} function, but produce plots in which one or
both of the axes use log scales.

@anchor{doc-semilogx}
@deftypefn {Function File} {} semilogx (@var{args})
Produce a two-dimensional plot using a log scale for the @var{x}
axis.  See the description of @code{plot} for a description of the
arguments that @code{semilogx} will accept.
@seealso{plot, semilogy, loglog}
@end deftypefn


@anchor{doc-semilogy}
@deftypefn {Function File} {} semilogy (@var{args})
Produce a two-dimensional plot using a log scale for the @var{y}
axis.  See the description of @code{plot} for a description of the
arguments that @code{semilogy} will accept.
@seealso{plot, semilogx, loglog}
@end deftypefn


@anchor{doc-loglog}
@deftypefn {Function File} {} loglog (@var{args})
Produce a two-dimensional plot using log scales for both axes.  See
the description of @code{plot} for a description of the arguments
that @code{loglog} will accept.
@seealso{plot, semilogx, semilogy}
@end deftypefn


The functions @code{bar}, @code{barh}, @code{stairs}, and @code{stem}
are useful for displaying discrete data.  For example,

@example
@group
hist (randn (10000, 1), 30);
@end group
@end example

@noindent
produces the histogram of 10,000 normally distributed random numbers
shown in @ref{fig:hist}.

@float Figure,fig:hist
@image{hist,8cm}
@caption{Histogram.}
@end float

@anchor{doc-bar}
@deftypefn {Function File} {} bar (@var{x}, @var{y})
@deftypefnx {Function File} {} bar (@var{y})
@deftypefnx {Function File} {} bar (@var{x}, @var{y}, @var{w})
@deftypefnx {Function File} {} bar (@var{x}, @var{y}, @var{w}, @var{style})
@deftypefnx {Function File} {@var{h} =} bar (@dots{}, @var{prop}, @var{val})
@deftypefnx {Function File} {} bar (@var{h}, @dots{})
Produce a bar graph from two vectors of x-y data.

If only one argument is given, it is taken as a vector of y-values
and the x coordinates are taken to be the indices of the elements.

The default width of 0.8 for the bars can be changed using @var{w}. 

If @var{y} is a matrix, then each column of @var{y} is taken to be a
separate bar graph plotted on the same graph. By default the columns
are plotted side-by-side. This behavior can be changed by the @var{style}
argument, which can take the values @code{"grouped"} (the default),
or @code{"stacked"}.

The optional return value @var{h} provides a handle to the patch object.
Whereas the option input handle @var{h} allows an axis handle to be passed.
Properties of the patch graphics object can be changed using 
@var{prop}, @var{val} pairs.

@seealso{barh, plot}
@end deftypefn


@anchor{doc-barh}
@deftypefn {Function File} {} barh (@var{x}, @var{y})
@deftypefnx {Function File} {} barh (@var{y})
@deftypefnx {Function File} {} barh (@var{x}, @var{y}, @var{w})
@deftypefnx {Function File} {} barh (@var{x}, @var{y}, @var{w}, @var{style})
@deftypefnx {Function File} {@var{h} =} barh (@dots{}, @var{prop}, @var{val})
@deftypefnx {Function File} {} barh (@var{h}, @dots{})
Produce a horizontal bar graph from two vectors of x-y data.

If only one argument is given, it is taken as a vector of y-values
and the x coordinates are taken to be the indices of the elements.

The default width of 0.8 for the bars can be changed using @var{w}. 

If @var{y} is a matrix, then each column of @var{y} is taken to be a
separate bar graph plotted on the same graph. By default the columns
are plotted side-by-side. This behavior can be changed by the @var{style}
argument, which can take the values @code{"grouped"} (the default),
or @code{"stacked"}.

The optional return value @var{h} provides a handle to the patch object.
Whereas the option input handle @var{h} allows an axis handle to be passed.
Properties of the patch graphics object can be changed using 
@var{prop}, @var{val} pairs.

@seealso{bar, plot}
@end deftypefn


@anchor{doc-hist}
@deftypefn {Function File} {} hist (@var{y}, @var{x}, @var{norm})
Produce histogram counts or plots.

With one vector input argument, plot a histogram of the values with
10 bins.  The range of the histogram bins is determined by the range
of the data.  With one matrix input argument, plot a hystogram where
each bin contains a bar per input column.

Given a second scalar argument, use that as the number of bins.

Given a second vector argument, use that as the centers of the bins,
with the width of the bins determined from the adjacent values in
the vector.

If third argument is provided, the histogram is normalised such that
the sum of the bars is equal to @var{norm}.

Extreme values are lumped in the first and last bins.

With two output arguments, produce the values @var{nn} and @var{xx} such
that @code{bar (@var{xx}, @var{nn})} will plot the histogram.
@seealso{bar}
@end deftypefn


@anchor{doc-stairs}
@deftypefn {Function File} {} stairs (@var{x}, @var{y})
Produce a stairstep plot.  The arguments may be vectors or matrices.

If only one argument is given, it is taken as a vector of y-values
and the x coordinates are taken to be the indices of the elements.

If two output arguments are specified, the data are generated but
not plotted.  For example,

@example
stairs (x, y);
@end example

@noindent
and

@example
@group
[xs, ys] = stairs (x, y);
plot (xs, ys);
@end group
@end example

@noindent
are equivalent.
@seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
bar, xlabel, ylabel, title}
@end deftypefn


@anchor{doc-stem}
@deftypefn {Function File} {@var{h} =} stem (@var{x}, @var{y}, @var{linespec})
Plot a stem graph and return the handles of the line and marker
objects used to draw the stems.  The default color is @code{"r"}
(red).  The default line style is @code{"-"} and the default marker is
@code{"o"}.

For example,
@example
x = 1:10;
stem (x);
@end example
@noindent
plots 10 stems with heights from 1 to 10;

@example
x = 1:10;
y = ones (1, length (x))*2.*x;
stem (x, y);
@end example
@noindent
plots 10 stems with heights from 2 to 20;

@example
x = 1:10;
y = ones (size (x))*2.*x;
h = stem (x, y, "b");
@end example
@noindent
plots 10 bars with heights from 2 to 20
(the color is blue, and @var{h} is a 2-by-10 array of handles in
which the first row holds the line handles and
the second row holds the marker handles);

@example
x = 1:10;
y = ones (size (x))*2.*x;
h = stem (x, y, "-.k");
@end example
@noindent
plots 10 stems with heights from 2 to 20
(the color is black, line style is @code{"-."}, and @var{h} is a 2-by-10
array of handles in which the first row holds the line handles and
the second row holds the marker handles);

@example
x = 1:10;
y = ones (size (x))*2.*x;
h = stem (x, y, "-.k.");
@end example
@noindent
plots 10 stems with heights from 2 to 20
(the color is black, line style is @code{"-."} and the marker style
is @code{"."}, and @var{h} is a 2-by-10 array of handles in which the
first row holds the line handles and the second row holds the marker
handles);

@example
x = 1:10;
y = ones (size (x))*2.*x;
h = stem (x, y, "fill");
@end example
@noindent
plots 10 stems with heights from 2 to 20
(the color is rgb-triple defined, the line style is @code{"-"},
the marker style is @code{"o"}, and @var{h} is a 2-by-10 array of
handles in which the first row holds the line handles and the second
row holds the marker handles).

Color definitions with rgb-triples are not valid!
@seealso{bar, barh, plot}
@end deftypefn


The @code{contour}, @code{contourf} and @code{contourc} functions
produce two-dimensional contour plots from three dimensional data.

@anchor{doc-contour}
@deftypefn {Function File} {} contour (@var{z})
@deftypefnx {Function File} {} contour (@var{z}, @var{vn})
@deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z})
@deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z}, @var{vn})
@deftypefnx {Function File} {} contour (@dots{}, @var{style})
@deftypefnx {Function File} {} contour (@var{h}, @dots{})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contour (@dots{})
Plot level curves (contour lines) of the matrix @var{z}, using the
contour matrix @var{c} computed by @code{contourc} from the same
arguments; see the latter for their interpretation.  The set of
contour levels, @var{c}, is only returned if requested.  For example:

@example
@group
x = 0:2;
y = x;
z = x' * y;
contour (x, y, z, 2:3)
@end group
@end example

The style to use for the plot can be defined with a line style @var{style}
in a similar manner to the line styles used with the @code{plot} command.
Any markers defined by @var{style} are ignored.

The optional input and output argument @var{h} allows an axis handle to 
be passed to @code{contour} and the handles to the contour objects to be
returned.
@seealso{contourc, patch, plot}
@end deftypefn


@anchor{doc-contourf}
@deftypefn {Function File} {[@var{c}, @var{h}] =} contourf (@var{x}, @var{y}, @var{z}, @var{lvl})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{x}, @var{y}, @var{z}, @var{n})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{x}, @var{y}, @var{z})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{z}, @var{n})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{z}, @var{lvl})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{z})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@var{ax}, @dots{})
@deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@dots{}, @var{"property"}, @var{val})
Compute and plot filled contours of the matrix @var{z}.
Parameters @var{x}, @var{y} and @var{n} or @var{lvl} are optional.

The return value @var{c} is a 2xn matrix containing the contour lines
as described in the help to the contourc function.

The return value @var{h} is handle-vector to the patch objects creating
the filled contours.

If @var{x} and @var{y} are ommited they are taken as the row/column
index of @var{z}.  @var{n} is a scalar denoting the number of lines
to compute.  Alternatively @var{lvl} is a vector containing the
contour levels. If only one value (e.g. lvl0) is wanted, set
@var{lvl} to [lvl0, lvl0].  If both @var{n} or @var{lvl} are omitted
a default value of 10 contour level is assumed.

If provided, the filled contours are added to the axes object
@var{ax} instead of the current axis.

The following example plots filled contours of the @code{peaks}
function.
@example
[x, y, z] = peaks (50);
contourf (x, y, z, -7:9)
@end example
@seealso{contour, contourc, patch}
@end deftypefn


@anchor{doc-contourc}
@deftypefn {Function File} {[@var{c}, @var{lev}] =}  contourc (@var{x}, @var{y}, @var{z}, @var{vn})
Compute isolines (contour lines) of the matrix @var{z}. 
Parameters @var{x}, @var{y} and @var{vn} are optional.

The return value @var{lev} is a vector of the contour levels.
The return value @var{c} is a 2 by @var{n} matrix containing the
contour lines in the following format

@example
@var{c} = [lev1, x1, x2, ..., levn, x1, x2, ... 
     len1, y1, y2, ..., lenn, y1, y2, ...]
@end example

@noindent
in which contour line @var{n} has a level (height) of @var{levn} and
length of @var{lenn}.

If @var{x} and @var{y} are omitted they are taken as the row/column 
index of @var{z}.  @var{vn} is either a scalar denoting the number of lines 
to compute or a vector containing the values of the lines. If only one 
value is wanted, set @code{@var{vn} = [val, val]};
If @var{vn} is omitted it defaults to 10.

For example,
@example
@group
x = 0:2;
y = x;
z = x' * y;
contourc (x, y, z, 2:3)
@result{}   2.0000   2.0000   1.0000   3.0000   1.5000   2.0000
     2.0000   1.0000   2.0000   2.0000   2.0000   1.5000

@end group
@end example
@seealso{contour}
@end deftypefn


The @code{errorbar}, @code{semilogxerr}, @code{semilogyerr}, and
@code{loglogerr} functions produces plots with error bar markers.  For
example,

@example
x = 0:0.1:10;
y = sin (x);
yp =  0.1 .* randn (size (x));
ym = -0.1 .* randn (size (x));
errorbar (x, sin (x), ym, yp);
@end example

@noindent
produces the figure shown in @ref{fig:errorbar}.

@float Figure,fig:errorbar
@image{errorbar,8cm}
@caption{Errorbar plot.}
@end float

@anchor{doc-errorbar}
@deftypefn {Function File} {} errorbar (@var{args})
This function produces two-dimensional plots with errorbars. Many
different combinations of arguments are possible.  The simplest form is

@example
errorbar (@var{y}, @var{ey})
@end example

@noindent
where the first argument is taken as the set of @var{y} coordinates
and the second argument @var{ey} is taken as the errors of the
@var{y} values. @var{x} coordinates are taken to be the indices
of the elements, starting with 1.

If more than two arguments are given, they are interpreted as

@example
errorbar (@var{x}, @var{y}, @dots{}, @var{fmt}, @dots{})
@end example

@noindent
where after @var{x} and @var{y} there can be up to four error
parameters such as @var{ey}, @var{ex}, @var{ly}, @var{uy} etc.,
depending on the plot type. Any number of argument sets may appear,
as long as they are separated with a format string @var{fmt}.

If @var{y} is a matrix, @var{x} and error parameters must also be matrices
having same dimensions. The columns of @var{y} are plotted versus the
corresponding columns of @var{x} and errorbars are drawn from
the corresponding columns of error parameters.

If @var{fmt} is missing, yerrorbars ("~") plot style is assumed.

If the @var{fmt} argument is supplied, it is interpreted as in
normal plots. In addition the following plot styles are supported by
errorbar:

@table @samp
@item ~
Set yerrorbars plot style (default).

@item >
Set xerrorbars plot style.

@item ~>
Set xyerrorbars plot style.

@item #
Set boxes plot style.

@item #~
Set boxerrorbars plot style.

@item #~>
Set boxxyerrorbars plot style.
@end table

Examples:

@example
errorbar (@var{x}, @var{y}, @var{ex}, ">")
@end example

produces an xerrorbar plot of @var{y} versus @var{x} with @var{x}
errorbars drawn from @var{x}-@var{ex} to @var{x}+@var{ex}.

@example
errorbar (@var{x}, @var{y1}, @var{ey}, "~",
@var{x}, @var{y2}, @var{ly}, @var{uy})
@end example

produces yerrorbar plots with @var{y1} and @var{y2} versus @var{x}.
Errorbars for @var{y1} are drawn from @var{y1}-@var{ey} to
@var{y1}+@var{ey}, errorbars for @var{y2} from @var{y2}-@var{ly} to
@var{y2}+@var{uy}.

@example
errorbar (@var{x}, @var{y}, @var{lx}, @var{ux},
@var{ly}, @var{uy}, "~>")
@end example

produces an xyerrorbar plot of @var{y} versus @var{x} in which
@var{x} errorbars are drawn from @var{x}-@var{lx} to @var{x}+@var{ux}
and @var{y} errorbars from @var{y}-@var{ly} to @var{y}+@var{uy}.
@seealso{semilogxerr, semilogyerr, loglogerr}
@end deftypefn


@anchor{doc-semilogxerr}
@deftypefn {Function File} {} semilogxerr (@var{args})
Produce two-dimensional plots on a semilogarithm axis with errorbars.
Many different combinations of arguments are possible.  The most used
form is

@example
semilogxerr (@var{x}, @var{y}, @var{ey}, @var{fmt})
@end example

@noindent
which produces a semi-logarithm plot of @var{y} versus @var{x}
with errors in the @var{y}-scale defined by @var{ey} and the plot
format defined by @var{fmt}. See errorbar for available formats and 
additional information.
@seealso{errorbar, loglogerr semilogyerr}
@end deftypefn


@anchor{doc-semilogyerr}
@deftypefn {Function File} {} semilogyerr (@var{args})
Produce two-dimensional plots on a semilogarithm axis with errorbars.
Many different combinations of arguments are possible.  The most used
form is

@example
semilogyerr (@var{x}, @var{y}, @var{ey}, @var{fmt})
@end example

@noindent
which produces a semi-logarithm plot of @var{y} versus @var{x}
with errors in the @var{y}-scale defined by @var{ey} and the plot
format defined by @var{fmt}.  See errorbar for available formats and 
additional information.
@seealso{errorbar, loglogerr semilogxerr}
@end deftypefn


@anchor{doc-loglogerr}
@deftypefn {Function File} {} loglogerr (@var{args})
Produce two-dimensional plots on double logarithm axis with
errorbars.  Many different combinations of arguments are possible.
The most used form is

@example
loglogerr (@var{x}, @var{y}, @var{ey}, @var{fmt})
@end example

@noindent
which produces a double logarithm plot of @var{y} versus @var{x} 
with errors in the @var{y}-scale defined by @var{ey} and the plot
format defined by @var{fmt}. See errorbar for available formats and 
additional information.
@seealso{errorbar, semilogxerr, semilogyerr}
@end deftypefn


Finally, the @code{polar} function allows you to easily plot data in
polar coordinates.  However, the display coordinates remain rectangular
and linear.  For example,

@example
polar (0:0.1:10*pi, 0:0.1:10*pi);
@end example

@noindent
produces the spiral plot shown in @ref{fig:polar}.

@float Figure,fig:polar
@image{polar,8cm}
@caption{Polar plot.}
@end float

@anchor{doc-polar}
@deftypefn {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt})
Make a two-dimensional plot given the polar coordinates @var{theta} and
@var{rho}.

The optional third argument specifies the line type.
@seealso{plot}
@end deftypefn


@anchor{doc-pie}
@deftypefn {Function File} {} pie (@var{y})
@deftypefnx {Function File} {} pie (@var{y}, @var{explode})
@deftypefnx {Function File} {} pie (@dots{}, @var{labels})
@deftypefnx {Function File} {} pie (@var{h}, @dots{});
@deftypefnx {Function File} {@var{h} =} pie (@dots{});
Produce a pie chart. 

Called with a single vector argument, produces a pie chart of the
elements in @var{x}, with the size of the slice determined by percentage
size of the values of @var{x}.

The variable @var{explode} is a vector of the same length as @var{x} that
if non zero 'explodes' the slice from the pie chart.

If given @var{labels} is a cell array of strings of the same length as
@var{x}, giving the labels of each of the slices of the pie chart. 

The optional return value @var{h} provides a handle to the patch object.

@seealso{bar, stem}
@end deftypefn


@anchor{doc-quiver}
@deftypefn {Function File} {} quiver (@var{u}, @var{v})
@deftypefnx {Function File} {} quiver (@var{x}, @var{y}, @var{u}, @var{v})
@deftypefnx {Function File} {} quiver (@dots{}, @var{s})
@deftypefnx {Function File} {} quiver (@dots{}, @var{style})
@deftypefnx {Function File} {} quiver (@dots{}, 'filled')
@deftypefnx {Function File} {} quiver (@var{h}, @dots{})
@deftypefnx {Function File} {@var{h} =} quiver (@dots{})

Plot the @code{(@var{u}, @var{v})} components of a vector field in 
an @code{(@var{x}, @var{y})} meshgrid. If the grid is uniform, you can 
specify @var{x} and @var{y} as vectors.

If @var{x} and @var{y} are undefined they are assumed to be
@code{(1:@var{m}, 1:@var{n})} where @code{[@var{m}, @var{n}] = 
size(@var{u})}.

The variable @var{s} is a scalar defining a scaling factor to use for
 the arrows of the field relative to the mesh spacing. A value of 0 
disables all scaling. The default value is 1.

The style to use for the plot can be defined with a line style @var{style}
in a similar manner to the line styles used with the @code{plot} command.
If a marker is specified then markers at the grid points of the vectors are
printed rather than arrows. If the argument 'filled' is given then the
markers as filled.

The optional return value @var{h} provides a list of handles to the 
the parts of the vector field (body, arrow and marker).

@example
@group
[x, y] = meshgrid (1:2:20);
quiver (x, y, sin (2*pi*x/10), sin (2*pi*y/10));
@end group
@end example

@seealso{plot}
@end deftypefn


@anchor{doc-pcolor}
@deftypefn {Function File} {} pcolor (@var{x}, @var{y}, @var{c})
@deftypefnx {Function File} {} pcolor (@var{c})
Density plot for given matrices @var{x}, and @var{y} from @code{meshgrid} and
a matrix @var{c} corresponding to the @var{x} and @var{y} coordinates of
the mesh's vertices. If @var{x} and @var{y} are vectors, then a typical vertex
is (@var{x}(j), @var{y}(i), @var{c}(i,j)).  Thus, columns of @var{c}
correspond to different @var{x} values and rows of @var{c} correspond
to different @var{y} values.

The @code{colormap} is scaled to the extents of @var{c}.
Limits may be placed on the color axis by the
command @code{caxis}, or by setting the @code{clim} property of the
parent axis.

The face color of each cell of the mesh is determined by interpolating
the values of @var{c} for the cell's vertices. Contrast this with 
@code{imagesc} which renders one cell for each element of @var{c}.

@code{shading} modifies an attribute determining the manner by which the
face color of each cell is interpolated from the values of @var{c},
and the visibility of the cells' edges. By default the attribute is
"faceted", which renders a single color for each cell's face with the edge
visible.

@var{h} is the handle to the surface object.

@seealso{caxis, contour, meshgrid, imagesc, shading}
@end deftypefn


@anchor{doc-area}
@deftypefn {Function File} {} area (@var{x}, @var{y})
@deftypefnx {Function File} {} area (@var{x}, @var{y}, @var{lvl})
@deftypefnx {Function File} {} area (@dots{}, @var{prop}, @var{val}, @dots{})
@deftypefnx {Function File} {} area (@var{y}, @dots{})
@deftypefnx {Function File} {} area (@var{h}, @dots{})
@deftypefnx {Function File} {@var{h} =} area (@dots{})
Area plot of cumulative sum of the columns of @var{y}. This shows the
contributions of a value to a sum, and is functionally similar to 
@code{plot (@var{x}, cumsum (@var{y}, 2))}, except that the area under 
the curve is shaded.

If the @var{x} argument is omitted it is assumed to be given by
@code{1 : rows (@var{y})}. A value @var{lvl} can be defined that determines
where the base level of the shading under the curve should be defined.

Additional arguments to the @code{area} function are passed to the 
@code{patch}. The optional return value @var{h} provides a handle to 
the list of patch objects.
@seealso{plot, patch}
@end deftypefn


The axis function may be used to change the axis limits of an existing
plot and various other axis properties, such as the aspect ratio and the
appearance of tic marks.

@anchor{doc-axis}
@deftypefn {Function File} {} axis (@var{limits})
Set axis limits for plots.

The argument @var{limits} should be a 2, 4, or 6 element vector.  The
first and second elements specify the lower and upper limits for the x
axis.  The third and fourth specify the limits for the y axis, and the
fifth and sixth specify the limits for the z axis.

Without any arguments, @code{axis} turns autoscaling on.  

With one output argument, @code{x=axis} returns the current axes 

The vector argument specifying limits is optional, and additional
string arguments may be used to specify various axis properties.  For
example,

@example
axis ([1, 2, 3, 4], "square");
@end example

@noindent
forces a square aspect ratio, and

@example
axis ("labely", "tic");
@end example

@noindent
turns tic marks on for all axes and tic mark labels on for the y-axis
only.

@noindent
The following options control the aspect ratio of the axes.

@table @code
@item "square"
Force a square aspect ratio.
@item "equal"
Force x distance to equal y-distance.
@item "normal"
Restore the balance.
@end table

@noindent
The following options control the way axis limits are interpreted.

@table @code
@item "auto" 
Set the specified axes to have nice limits around the data
or all if no axes are specified.
@item "manual" 
Fix the current axes limits.
@item "tight"
Fix axes to the limits of the data (not implemented).
@end table

@noindent
The option @code{"image"} is equivalent to @code{"tight"} and
@code{"equal"}.

@noindent
The following options affect the appearance of tic marks.

@table @code
@item "on" 
Turn tic marks and labels on for all axes.
@item "off"
Turn tic marks off for all axes.
@item "tic[xyz]"
Turn tic marks on for all axes, or turn them on for the
specified axes and off for the remainder.
@item "label[xyz]"
Turn tic labels on for all axes, or turn them on for the 
specified axes and off for the remainder.
@item "nolabel"
Turn tic labels off for all axes.
@end table
Note, if there are no tic marks for an axis, there can be no labels.

@noindent
The following options affect the direction of increasing values on
the axes.

@table @code
@item "ij"
Reverse y-axis, so lower values are nearer the top.
@item "xy" 
Restore y-axis, so higher values are nearer the top. 
@end table

If an axes handle is passed as the first argument, then operate on
this axes rather than the current axes.
@end deftypefn


Similarly the axis limits of the colormap can be changed with the caxis
function.

@anchor{doc-caxis}
@deftypefn {Function File} {} caxis (@var{limits})
@deftypefnx {Function File} {} caxis (@var{h}, @dots{})
Set color axis limits for plots.

The argument @var{limits} should be a 2 element vector specifying the 
lower and upper limits to assign to the first and last value in the
colormap. Values outside this range are clamped to the first and last
colormap entries. 

If @var{limits} is 'auto', then automatic colormap scaling is applied,
whereas if @var{limits} is 'manual' the colormap scaling is set to manual.

Called without any arguments to current color axis limits are returned.

If an axes handle is passed as the first argument, then operate on
this axes rather than the current axes.
@end deftypefn


@node Three-Dimensional Plotting
@subsection Three-Dimensional Plotting

The function @code{mesh} produces mesh surface plots.  For example,

@example
@group
tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);
@end group
@end example

@noindent
produces the familiar ``sombrero'' plot shown in @ref{fig:mesh}.  Note
the use of the function @code{meshgrid} to create matrices of X and Y
coordinates to use for plotting the Z data.  The @code{ndgrid} function
is similar to @code{meshgrid}, but works for N-dimensional matrices.

@float Figure,fig:mesh
@image{mesh,8cm}
@caption{Mesh plot.}
@end float

The @code{meshc} function is similar to @code{mesh}, but also produces a
plot of contours for the surface.

The @code{plot3} function displays arbitrary three-dimensional data,
without requiring it to form a surface.  For example

@example
@group
t = 0:0.1:10*pi;
r = linspace (0, 1, numel (t));
z = linspace (0, 1, numel (t));
plot3 (r.*sin(t), r.*cos(t), z);
@end group
@end example

@noindent
displays the spiral in three dimensions shown in @ref{fig:plot3}.

@float Figure,fig:plot3
@image{plot3,8cm}
@caption{Three dimensional spiral.}
@end float

Finally, the @code{view} function changes the viewpoint for
three-dimensional plots.

@anchor{doc-mesh}
@deftypefn {Function File} {} mesh (@var{x}, @var{y}, @var{z})
Plot a mesh given matrices @var{x}, and @var{y} from @code{meshgrid} and
a matrix @var{z} corresponding to the @var{x} and @var{y} coordinates of
the mesh.  If @var{x} and @var{y} are vectors, then a typical vertex
is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, columns of @var{z}
correspond to different @var{x} values and rows of @var{z} correspond
to different @var{y} values.
@seealso{meshgrid, contour}
@end deftypefn


@anchor{doc-meshc}
@deftypefn {Function File} {} meshc (@var{x}, @var{y}, @var{z})
Plot a mesh and contour given matrices @var{x}, and @var{y} from 
@code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and 
@var{y} coordinates of the mesh.  If @var{x} and @var{y} are vectors, 
then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, 
columns of @var{z} correspond to different @var{x} values and rows of 
@var{z} correspond to different @var{y} values.
@seealso{meshgrid, mesh, contour}
@end deftypefn


@anchor{doc-hidden}
@deftypefn {Function File} {} hidden (@var{mode})
@deftypefnx {Function File} {} hidden ()
Manipulation the mesh hidden line removal. Called with no argument
the hidden line removal is toggled. The argument @var{mode} can be either
'on' or 'off' and the set of the hidden line removal is set accordingly.
@seealso{mesh, meshc, surf}
@end deftypefn


@anchor{doc-surf}
@deftypefn {Function File} {} surf (@var{x}, @var{y}, @var{z})
Plot a surface given matrices @var{x}, and @var{y} from @code{meshgrid} and
a matrix @var{z} corresponding to the @var{x} and @var{y} coordinates of
the mesh.  If @var{x} and @var{y} are vectors, then a typical vertex
is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, columns of @var{z}
correspond to different @var{x} values and rows of @var{z} correspond
to different @var{y} values.
@seealso{mesh, surface}
@end deftypefn


@anchor{doc-surfc}
@deftypefn {Function File} {} surfc (@var{x}, @var{y}, @var{z})
Plot a surface and contour given matrices @var{x}, and @var{y} from 
@code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and 
@var{y} coordinates of the mesh.  If @var{x} and @var{y} are vectors, 
then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, 
columns of @var{z} correspond to different @var{x} values and rows of 
@var{z} correspond to different @var{y} values.
@seealso{meshgrid, surf, contour}
@end deftypefn


@anchor{doc-meshgrid}
@deftypefn {Function File} {[@var{xx}, @var{yy}, @var{zz}] =} meshgrid (@var{x}, @var{y}, @var{z})
@deftypefnx {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x}, @var{y})
@deftypefnx {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x})
Given vectors of @var{x} and @var{y} and @var{z} coordinates, and
returning 3 arguments, return three dimensional arrays corresponding
to the @var{x}, @var{y}, and @var{z} coordinates of a mesh.  When
returning only 2 arguments, return matrices corresponding to the
@var{x} and @var{y} coordinates of a mesh.  The rows of @var{xx} are
copies of @var{x}, and the columns of @var{yy} are copies of @var{y}.
If @var{y} is omitted, then it is assumed to be the same as @var{x},
and @var{z} is assumed the same as @var{y}.
@seealso{mesh, contour}
@end deftypefn


@anchor{doc-ndgrid}
@deftypefn {Function File} {[@var{y1}, @var{y2}, @dots{},  @var{y}n] =} ndgrid (@var{x1}, @var{x2}, @dots{}, @var{x}n)
@deftypefnx {Function File} {[@var{y1}, @var{y2}, @dots{},  @var{y}n] =} ndgrid (@var{x})
Given n vectors @var{x1}, @dots{} @var{x}n, @code{ndgrid} returns
n arrays of dimension n.  The elements of the ith output argument
contains the elements of the vector @var{x}i repeated over all
dimensions different from the ith dimension.  Calling ndgrid with
only one input argument @var{x} is equivalent of calling ndgrid with
all n input arguments equal to @var{x}:

[@var{y1}, @var{y2}, @dots{},  @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x})
@seealso{meshgrid}
@end deftypefn


@anchor{doc-plot3}
@deftypefn {Function File} {} plot3 (@var{args})
Produce three-dimensional plots.  Many different combinations of
arguments are possible.  The simplest form is

@example
plot3 (@var{x}, @var{y}, @var{z})
@end example

@noindent
in which the arguments are taken to be the vertices of the points to
be plotted in three dimensions. If all arguments are vectors of the
same length, then a single continuous line is drawn. If all arguments
are matrices, then each column of the matrices is treated as a
separate line.  No attempt is made to transpose the arguments to make
the number of rows match.

If only two arguments are given, as

@example
plot3 (@var{x}, @var{c})
@end example

@noindent
the real and imaginary parts of the second argument are used
as the @var{y} and @var{z} coordinates, respectively.

If only one argument is given, as

@example
plot3 (@var{c})
@end example

@noindent
the real and imaginary parts of the argument are used as the @var{y}
and @var{z} values, and they are plotted versus their index.

Arguments may also be given in groups of three as

@example
plot3 (@var{x1}, @var{y1}, @var{z1}, @var{x2}, @var{y2}, @var{z2}, @dots{})
@end example

@noindent
in which each set of three arguments is treated as a separate line or
set of lines in three dimensions.

To plot multiple one- or two-argument groups, separate each group
with an empty format string, as

@example
plot3 (@var{x1}, @var{c1}, "", @var{c2}, "", @dots{})
@end example

An example of the use of @code{plot3} is

@example
@group
   z = [0:0.05:5];
   plot3 (cos(2*pi*z), sin(2*pi*z), z, ";helix;");
   plot3 (z, exp(2i*pi*z), ";complex sinusoid;");
@end group
@end example
@seealso{plot}
@end deftypefn


@anchor{doc-view}
@deftypefn {Function File} {} view (@var{azimuth}, @var{elevation})
@deftypefnx {Function File} {} view (@var{dims})
@deftypefnx {Function File} {[@var{azimuth}, @var{elevation}] =} view ()
Set or get the viewpoint for the current axes.
@end deftypefn


@anchor{doc-shading}
@deftypefn {Function File} {} shading (@var{type})
@deftypefnx {Function File} {} shading (@var{ax}, @dots{})
Set the shading of surface or patch graphic objects. Valid arguments
for @var{type} are

@table @code
@item "flat"
Single colored patches with invisible edges.

@item "faceted"
Single colored patches with visible edges.

@item "interp"
Color between patch vertices are interpolated and the patch edges are
invisible.
@end table

If @var{ax} is given the shading is applied to axis @var{ax} instead
of the current axis.
@end deftypefn


@node Plot Annotations
@subsection Plot Annotations

You can add titles, axis labels, legends, and arbitrary text to an
existing plot.  For example,

@example
@group
x = -10:0.1:10;
plot (x, sin (x));
title ("sin(x) for x = -10:0.1:10");
xlabel ("x");
ylabel ("sin (x)");
text (pi, 0.7, "arbitrary text");
legend ("sin (x)");
@end group
@end example

The functions @code{grid} and @code{box} may also be used to add grid
and border lines to the plot.  By default, the grid is off and the
border lines are on.

@anchor{doc-title}
@deftypefn {Function File} {} title (@var{title})
Create a title object and return a handle to it.
@end deftypefn


@anchor{doc-legend}
@deftypefn {Function File} {} legend (@var{st1}, @var{st2}, @dots{})
@deftypefnx {Function File} {} legend (@var{st1}, @var{st2}, @dots{}, "location", @var{pos})
@deftypefnx {Function File} {} legend (@var{matstr})
@deftypefnx {Function File} {} legend (@var{matstr}, "location", @var{pos})
@deftypefnx {Function File} {} legend (@var{cell})
@deftypefnx {Function File} {} legend (@var{cell}, "location", @var{pos})
@deftypefnx {Function File} {} legend ('@var{func}')

Display a legend for the current axes using the specified strings
as labels.  Legend entries may be specified as individual character
string arguments, a character array, or a cell array of character
strings.  Legend works on line graphs, bar graphs, etc.  A plot must
exist before legend is called.

The optional parameter @var{pos} specifies the location of the legend
as follows:

@multitable @columnfractions 0.06 0.14 0.80
@item @tab north @tab
  center top
@item @tab south @tab
  center bottom
@item @tab east @tab
  right center
@item @tab west @tab
  left center
@item @tab northeast @tab
  right top (default)
@item @tab northwest @tab
  left top
@item @tab southeast @tab
  right bottom
@item @tab southwest @tab
  left bottom
@item 
@item @tab outside @tab
  can be appended to any location string
@end multitable

Some specific functions are directly available using @var{func}:

@table @asis
@item "show"
  Show legends from the plot
@item "hide"
@itemx "off"
  Hide legends from the plot
@item "boxon"
  Draw a box around legends
@item "boxoff"
  Withdraw the box around legends
@item "left"
  Text is to the left of the keys
@item "right"
  Text is to the right of the keys
@end table
@end deftypefn


@anchor{doc-text}
@deftypefn {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{label})
@deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label})
@deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{label}, @var{p1}, @var{v1}, @dots{})
@deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label}, @var{p1}, @var{v1}, @dots{})
Create a text object with text @var{label} at position @var{x},
@var{y}, @var{z} on the current axes.  Property-value pairs following
@var{label} may be used to specify the appearance of the text.
@end deftypefn


See @ref{Text Properties} for the properties that you can set.

@anchor{doc-xlabel}
@deftypefn {Function File} {} xlabel (@var{string})
@deftypefnx {Function File} {} ylabel (@var{string})
@deftypefnx {Function File} {} zlabel (@var{string})
@deftypefnx {Function File} {} xlabel (@var{h}, @var{string})
Specify x, y, and z axis labels for the current figure. If @var{h} is
specified then label the axis defined by @var{h}.
@seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
bar, stairs,  ylabel, title}
@end deftypefn


@anchor{doc-box}
@deftypefn {Function File} {} box (@var{arg})
@deftypefnx {Function File} {} box (@var{h}, @dots{})
Control the display of a border around the plot.
The argument may be either @code{"on"} or @code{"off"}.  If it is
omitted, the current box state is toggled.
@seealso{grid}
@end deftypefn


@anchor{doc-grid}
@deftypefn {Function File} {} grid (@var{arg})
@deftypefnx {Function File} {} grid ("minor", @var{arg2})
@deftypefnx {Function File} {} grid (@var{hax}, @dots{})
Force the display of a grid on the plot.
The argument may be either @code{"on"}, or @code{"off"}.
If it is omitted, the current grid state is toggled.

If @var{arg} is @code{"minor"} then the minor grid is toggled.  When
using a minor grid a second argument @var{arg2} is allowed, which can
be either @code{"on"} or @code{"off"} to explicitly set the state of
the minor grid.

If the first argument is an axis handle, @var{hax}, operate on the
specified axis object.
@seealso{plot}
@end deftypefn


@anchor{doc-colorbar}
@deftypefn {Function File} {} colorbar (@var{s})
@deftypefnx {Function File} {} colorbar ('peer', @var{h}, @dots{})
Adds a colorbar to the current axes. Valid values for @var{s} are

@table @asis
@item 'EastOutside'
Place the colorbar outside the plot to the right. This is the default.
@item 'East'
Place the colorbar inside the plot to the right.
@item 'WestOutside'
Place the colorbar outside the plot to the left.
@item 'West'
Place the colorbar inside the plot to the left.
@item 'NorthOutside'
Place the colorbar above the plot.
@item 'North'
Place the colorbar at the top of the plot.
@item 'SouthOutside'
Place the colorbar under the plot.
@item 'South'
Place the colorbar at the bottom of the plot.
@item 'Off', 'None'
Remove any existing colorbar from the plot.
@end table

If the argument 'peer' is given, then the following argument is treated
as the axes handle on which to add the colorbar.
@end deftypefn


@node Multiple Plots on One Page
@subsection Multiple Plots on One Page

Octave can display more than one plot in a single figure.  The simplest
way to do this is to use the @code{subplot} function to divide the plot
area into a series of subplot windows that are indexed by an integer.
For example,

@example
@group
subplot (2, 1, 1)
fplot (@@sin, [-10, 10]);
subplot (2, 1, 2)
fplot (@@cos, [-10, 10]);
@end group
@end example

@noindent
creates a figure with two separate axes, one displaying a sine wave and
the other a cosine wave.  The first call to subplot divides the figure
into two plotting areas (two rows and one column) and makes the first plot
area active.  The grid of plot areas created by @code{subplot} is
numbered in column-major order (top to bottom, left to right).

@anchor{doc-subplot}
@deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
@deftypefnx {Function File} {} subplot (@var{rcn})
Set up a plot grid with @var{cols} by @var{rows} subwindows and plot
in location given by @var{index}.

If only one argument is supplied, then it must be a three digit value
specifying the location in digits 1 (rows) and 2 (columns) and the plot
index in digit 3.

The plot index runs row-wise.  First all the columns in a row are filled
and then the next row is filled.

For example, a plot with 2 by 3 grid will have plot indices running as
follows:
@iftex
@tex
\vskip 10pt
\hfil\vbox{\offinterlineskip\hrule
\halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr
height13pt&1&2&3\cr height12pt&&&\cr\noalign{\hrule}
height13pt&4&5&6\cr height12pt&&&\cr\noalign{\hrule}}}
\hfil
\vskip 10pt
@end tex
@end iftex
@ifinfo
@display
@group
@example

+-----+-----+-----+
|  1  |  2  |  3  |
+-----+-----+-----+
|  4  |  5  |  6  |
+-----+-----+-----+
@end example
@end group
@end display
@end ifinfo
@seealso{plot}
@end deftypefn


@node Multiple Plot Windows
@subsection Multiple Plot Windows

You can open multiple plot windows using the @code{figure} function.
For example

@example
figure (1);
fplot (@@sin, [-10, 10]);
figure (2);
fplot (@@cos, [-10, 10]);
@end example

@noindent
creates two figures, with the first displaying a sine wave and
the second a cosine wave.  Figure numbers must be positive integers.

@anchor{doc-figure}
@deftypefn {Function File} {} figure (@var{n})
@deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{})
Set the current plot window to plot window @var{n}.  If no arguments are
specified, the next available window number is chosen.

Multiple property-value pairs may be specified for the figure, but they
must appear in pairs.
@end deftypefn


@node Printing Plots
@subsection Printing Plots

The @code{print} command allows you to save plots in a variety of
formats.  For example,

@example
print -deps foo.eps
@end example

@noindent
writes the current figure to an encapsulated PostScript file called
@file{foo.eps}.

@anchor{doc-print}
@deftypefn {Function File} {} print (@var{filename}, @var{options})
Print a graph, or save it to a file

@var{filename} defines the file name of the output file. If no
filename is specified, output is sent to the printer.

@var{options}:
@table @code
@item -P@var{printer}
  Set the @var{printer} name to which the graph is sent if no
@var{filename} is specified.
@item -color
@itemx -mono
  Monochrome or colour lines.
@item -solid
@itemx -dashed
  Solid or dashed lines.
@item -portrait
@itemx -landscape
  Plot orientation, as returned by "orient".
@item -d@var{device}
  Output device, where @var{device} is one of:
@table @code
@item ps
@itemx ps2
@itemx psc
@itemx psc2
    Postscript (level 1 and 2, mono and color)
@item eps
@itemx eps2
@itemx epsc
@itemx epsc2
    Encapsulated postscript (level 1 and 2, mono and color)
@item tex
@itemx epslatex
@itemx epslatexstandalone
@itemx pstex
@itemx pslatex
    Generate a LaTeX (or TeX) file for labels, and eps/ps for
    graphics.  The file produced by @code{epslatexstandalone} can be
    processed directly by LaTeX.  The other formats are intended to
    be included in a LaTeX (or TeX) document.  The @code{tex} device
    is the same as the @code{epslatex} device.
@item ill
@itemx aifm
    Adobe Illustrator
@item cdr
@itemx corel
    CorelDraw
@item dxf
    AutoCAD
@item emf
    Microsoft Enhanced Metafile
@item fig
    XFig.  If this format is selected the additional options
@code{-textspecial} or @code{-textnormal} can be used to control
    whether the special flag should be set for the text in the figure
    (default is @code{-textnormal}). 
@item hpgl
    HP plotter language
@item mf
    Metafont
@item png
    Portable network graphics
@item jpg
@itemx jpeg
    JPEG image
@item gif
    GIF image
@item pbm
    PBMplus
@item svg
    Scalable vector graphics
@item pdf
    Portable document format
@end table

  Other devices are supported by "convert" from ImageMagick.  Type
  system("convert") to see what formats are available.

  If the device is omitted, it is inferred from the file extension,
  or if there is no filename it is sent to the printer as postscript.

@itemx -S@var{xsize},@var{ysize}
  Plot size in pixels for PNG and SVG.  If using the command form of
  the print function, you must quote the @var{xsize},@var{ysize}
  option.  For example, by writing @code{"-S640,480"}.

@item -F@var{fontname}
@itemx -F@var{fontname}:@var{size}
@itemx -F:@var{size}
@var{fontname} set the postscript font (for use with postscript,
  aifm, corel and fig). By default, 'Helvetica' is set for PS/Aifm,
  and 'SwitzerlandLight' for Corel. It can also be 'Times-Roman'.
@var{size} is given in points. @var{fontname} is ignored for the
  fig device.
@end table

The filename and options can be given in any order.
@end deftypefn


@anchor{doc-orient}
@deftypefn {Function File} {} orient (@var{orientation})
Set the default print orientation.  Valid values for
@var{orientation} include @code{"landscape"} and @code{"portrait"}.
If called with no arguments, return the default print orientation.
@end deftypefn


@node Test Plotting Functions
@subsection Test Plotting Functions

The functions @code{sombrero} and @code{peaks} provide a way to check
that plotting is working.  Typing either @code{sombrero} or @code{peaks}
at the Octave prompt should display a three dimensional plot.

@anchor{doc-sombrero}
@deftypefn {Function File} {} sombrero (@var{n})
Produce the familiar three-dimensional sombrero plot using @var{n}
grid lines.  If @var{n} is omitted, a value of 41 is assumed.

The function plotted is

@example
z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2))
@end example
@seealso{surf, meshgrid, mesh}
@end deftypefn


@anchor{doc-peaks}
@deftypefn {Function File} {} peaks ()
@deftypefnx {Function File} {} peaks (@var{n})
@deftypefnx {Function File} {} peaks (@var{x}, @var{y})
@deftypefnx {Function File} {@var{z} =} peaks (@dots{})
@deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} peaks (@dots{})
Generate a function with lots of local maxima and minima. The function
has the form

@iftex
@tex
$f(x,y) = 3 (1 - x) ^ 2 e ^ {\left(-x^2 - (y+1)^2\right)} - 10 \left({x \over 5} - x^3 - y^5)\right) - {1 \over 3} e^{\left(-(x+1)^2 - y^2\right)}$
@end tex
@end iftex
@ifnottex
@verbatim
f(x,y) = 3*(1-x)^2*exp(-x^2 - (y+1)^2) ...
         - 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2) ...
         - 1/3*exp(-(x+1)^2 - y^2)
@end verbatim
@end ifnottex

Called without a return argument, @code{peaks} plots the surface of the 
above function using @code{mesh}. If @var{n} is a scalar, the @code{peaks}
returns the values of the above function on a @var{n}-by-@var{n} mesh over
the range @code{[-3,3]}. The default value for @var{n} is 49.

If @var{n} is a vector, then it represents the @var{x} and @var{y} values
of the grid on which to calculate the above function. The @var{x} and 
@var{y} values can be specified separately.
@seealso{surf, mesh, meshgrid}
@end deftypefn


@node Advanced Plotting
@section Advanced Plotting

@menu
* Graphics Objects::
* Graphics Object Properties::  
* Managing Default Properties::  
* Colors::
* Line Styles::
* Marker Styles::
* Interaction with gnuplot::    
@end menu

@node Graphics Objects
@subsection Graphics Objects

Plots in Octave are constructed from the following @dfn{graphics
objects}.  Each graphics object has a set of properties that define its
appearance and may also contain links to other graphics objects.
Graphics objects are only referenced by a numeric index, or @dfn{handle}.

@table @asis
@item root figure
@cindex root figure graphics object
@cindex graphics object, root figure
The parent of all figure objects.  The index for the root figure is
defined to be 0.

@item figure
@cindex figure graphics object
@cindex graphics object, figure
A figure window.

@item axes
@cindex axes graphics object
@cindex graphics object, axes
An set of axes.  This object is a child of a figure object and may be a
parent of line, text, image, patch, or surface objects.

@item line
@cindex line graphics object
@cindex graphics object, line
A line in two or three dimensions.

@item text
@cindex text graphics object
@cindex graphics object, text
Text annotations.

@item image
@cindex image graphics object
@cindex graphics object, image
A bitmap image.

@item patch
@cindex patch graphics object
@cindex graphics object, patch
A filled polygon, currently limited to two dimensions.

@item surface
@cindex surface graphics object
@cindex graphics object, surface 
A three-dimensional surface.
@end table

To determine whether an object is a graphics object index or a figure
index, use the functions @code{ishandle} and @code{isfigure}.

@anchor{doc-ishandle}
@deftypefn {Built-in Function} {} ishandle (@var{h})
Return true if @var{h} is a graphics handle and false otherwise.
@end deftypefn


@anchor{doc-isfigure}
@deftypefn {Function File} {} isfigure (@var{h})
Return true if @var{h} is a graphics handle that contains a figure
object and false otherwise.
@end deftypefn


The function @code{gcf} returns an index to the current figure object,
or creates one if none exists.  Similarly, @code{gca} returns the
current axes object, or creates one (and its parent figure object) if
none exists.

@anchor{doc-gcf}
@deftypefn {Function File} {} gcf ()
Return the current figure handle.  If a figure does not exist, create
one and return its handle.  The handle may then be used to examine or
set properties of the figure.  For example,

@example
@group
fplot (@@sin, [-10, 10]);
fig = gcf ();
set (fig, "visible", "off");
@end group
@end example

@noindent
plots a sine wave, finds the handle of the current figure, and then
makes that figure invisible.  Setting the visible property of the
figure to @code{"on"} will cause it to be displayed again.
@seealso{get, set}
@end deftypefn


@anchor{doc-gca}
@deftypefn {Function File} {} gca ()
Return a handle to the current axis object.  If no axis object
exists, create one and return its handle.  The handle may then be
used to examine or set properties of the axes.  For example,

@example
@group
ax = gca ();
set (ax, "position", [0.5, 0.5, 0.5, 0.5]);
@end group
@end example

@noindent
creates an empty axes object, then changes its location and size in
the figure window.
@seealso{get, set}
@end deftypefn


The @code{get} and @code{set} functions may be used to examine and set
properties for graphics objects.  For example,

@example
@group
get (0)
    @result{} ans =
       @{
         type = root figure
         currentfigure = [](0x0)
         children = [](0x0)
         visible = on
       @}
@end group
@end example

@noindent
returns a structure containing all the properties of the root figure.
As with all functions in Octave, the structure is returned by value, so
modifying it will not modify the internal root figure plot object.  To
do that, you must use the @code{set} function.  Also, note that in this
case, the @code{currentfigure} property is empty, which indicates that
there is no current figure window.

The @code{get} function may also be used to find the value of a single
property.  For example,

@example
@group
get (gca (), "xlim")
    @result{} [ 0 1 ]
@end group
@end example

@noindent
returns the range of the x-axis for the current axes object in the
current figure.

To set graphics object properties, use the set function.  For example,

@example
set (gca (), "xlim", [-10, 10]);
@end example

@noindent
sets the range of the x-axis for the current axes object in the current
figure to @samp{[-10, 10]}.  Additionally, calling set with a graphics
object index as the only argument returns a structure containing the
default values for all the properties for the given object type.  For
example,

@example
set (gca ())
@end example

@noindent
returns a structure containing the default property values for axes
objects.

@anchor{doc-get}
@deftypefn {Built-in Function} {} get (@var{h}, @var{p})
Return the named property @var{p} from the graphics handle @var{h}.
If @var{p} is omitted, return the complete property list for @var{h}.
If @var{h} is a vector, return a cell array including the property
values or lists respectively.
@end deftypefn


@anchor{doc-set}
@deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})
Set the named property value or vector @var{p} to the value @var{v}
for the graphics handle @var{h}.
@end deftypefn


@anchor{doc-ancestor}
@deftypefn {Function File} {@var{parent} =} ancestor (@var{h}, @var{type})
@deftypefnx {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}, 'toplevel')
Return the first ancestor of handle object @var{h} whose type matches
@var{type}, where @var{type} is a character string. If @var{type} is a
cell array of strings, return the first parent whose type matches
any of the given type strings.

If the handle object @var{h} is of type @var{type}, return @var{h}.

If @code{"toplevel"} is given as a 3rd argument, return the highest
parent in the object hierarchy that matches the condition, instead
of the first (nearest) one.
@seealso{get, set}
@end deftypefn


You can create axes, line, and patch objects directly using the
@code{axes}, @code{line}, and @code{patch} functions.  These objects
become children of the current axes object.

@anchor{doc-axes}
@deftypefn {Function File} {} axes ()
@deftypefnx {Function File} {} axes (@var{property}, @var{value}, @dots{})
@deftypefnx {Function File} {} axes (@var{h})
Create an axes object and return a handle to it.
@end deftypefn


@anchor{doc-line}
@deftypefn {Function File} {} line ()
@deftypefnx {Function File} {} line (@var{x}, @var{y})
@deftypefnx {Function File} {} line (@var{x}, @var{y}, @var{z})
@deftypefnx {Function File} {} line (@var{x}, @var{y}, @var{z}, @var{property}, @var{value}, @dots{})
Create line object from @var{x} and @var{y} and insert in current
axes object.  Return a handle (or vector of handles) to the line
objects created.

Multiple property-value pairs may be specified for the line, but they
must appear in pairs.
@end deftypefn


@anchor{doc-patch}
@deftypefn {Function File} {} patch ()
@deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c})
@deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}, @var{opts})
@deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{})
@deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val})
@deftypefnx {Function File} {} patch (@var{h}, @dots{})
@deftypefnx {Function File} {@var{h} = } patch (@dots{})
Create patch object from @var{x} and @var{y} with color @var{c} and
insert in the current axes object.  Return handle to patch object.

For a uniform colored patch, @var{c} can be given as an RGB vector,
scalar value referring to the current colormap, or string value (for
example, "r" or "red"). 
@end deftypefn


@anchor{doc-surface}
@deftypefn {Function File} {} surface (@var{x}, @var{y}, @var{z}, @var{c})
@deftypefnx {Function File} {} surface (@var{x}, @var{y}, @var{z})
@deftypefnx {Function File} {} surface (@var{z}, @var{c})
@deftypefnx {Function File} {} surface (@var{z})
@deftypefnx {Function File} {} surface (@dots{}, @var{prop}, @var{val})
@deftypefnx {Function File} {} surface (@var{h}, @dots{})
@deftypefnx {Function File} {@var{h} = } surface (@dots{})
Plot a surface graphic object given matrices @var{x}, and @var{y} from 
@code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and 
@var{y} coordinates of the surface.  If @var{x} and @var{y} are vectors,
then a typical vertex  is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, 
columns of @var{z} correspond to different @var{x} values and rows of 
@var{z} correspond to different @var{y} values. If @var{x} and @var{y}
are missing, they are constructed from size of the matrix @var{z}.

Any additional properties passed are assigned the the surface..
@seealso{surf, mesh, patch, line}
@end deftypefn


By default, Octave refreshes the plot window when a prompt is printed,
or when waiting for input.  To force an update at other times, call the
@code{drawnow} function.

@anchor{doc-drawnow}
@deftypefn {Function File} {} drawnow ()
Update and display the current graphics.

Octave automatically calls drawnow just before printing a prompt,
when @code{sleep} or @code{pause} is called, or while waiting for
command-line input.
@end deftypefn


Normally, high-level plot functions like @code{plot} or @code{mesh} call
@code{newplot} to initialize the state of the current axes so that the
next plot is drawn in a blank window with default property settings.  To
have two plots superimposed over one another, call the @code{hold}
function.  For example,

@example
@group
hold ("on");
x = -10:0.1:10;
plot (x, sin (x));
plot (x, cos (x));
hold ("off");
@end group
@end example

@noindent
displays sine and cosine waves on the same axes.  If the hold state is
off, consecutive plotting commands like this will only display the last
plot.

@anchor{doc-newplot}
@deftypefn {Function File} {} newplot ()
Prepare graphics engine to produce a new plot.  This function should
be called at the beginning of all high-level plotting functions.
@end deftypefn


@anchor{doc-hold}
@deftypefn {Function File} {} hold @var{args}
Tell Octave to `hold' the current data on the plot when executing
subsequent plotting commands.  This allows you to execute a series of
plot commands and have all the lines end up on the same figure.  The
default is for each new plot command to clear the plot device first.
For example, the command

@example
hold on
@end example

@noindent
turns the hold state on.  An argument of @code{"off"} turns the hold
state off, and @code{hold} with no arguments toggles the current hold
state.
@end deftypefn


@anchor{doc-ishold}
@deftypefn {Function File} {} ishold
Return true if the next line will be added to the current plot, or
false if the plot device will be cleared before drawing the next line.
@end deftypefn


To clear the current figure, call the @code{clf} function.  To bring it
to the top of the window stack, call the @code{shg} function.  To delete
a graphics object, call @code{delete} on its index.  To close the
figure window, call the @code{close} function.

@anchor{doc-clf}
@deftypefn {Function File} {} clf ()
@deftypefnx {Function File} {} clf ("reset")
@deftypefnx {Function File} {} clf (@var{hfig})
@deftypefnx {Function File} {} clf (@var{hfig}, "reset")
@deftypefnx {Function File} {@var{hfig} =} clf (@dots{})
Delete the children of the current figure with visible handles.
If @var{hfig} is specified and is an figure object handle, operate on it
instead of the current figure.  If the optional argument @code{"reset"}
is specified, also delete the figure's children with hidden handles.
@seealso{cla, close, delete}
@end deftypefn


@anchor{doc-shg}
@deftypefn {Function File} {} shg
Show the graph window.  Currently, this is the same as executing
@code{drawnow}.
@seealso{drawnow, figure}
@end deftypefn


@anchor{doc-delete}
@deftypefn {Function File} {} delete (@var{file})
@deftypefnx {Function File} {} delete (@var{h})
Delete the named file or figure handle.
@end deftypefn


@anchor{doc-close}
@deftypefn {Command} {} close
@deftypefnx {Command} {} close (@var{n})
@deftypefnx {Command} {} close all
@deftypefnx {Command} {} close all hidden
Close figure window(s) by calling the function specified by the
@code{"closerequestfcn"} property for each figure.  By default, the
function @code{closereq} is used.
@seealso{closereq}
@end deftypefn


@anchor{doc-closereq}
@deftypefn {Function File} {} closereq ()
Close the current figure and delete all graphics objects associated
with it.
@seealso{close, delete}
@end deftypefn


@node Graphics Object Properties
@subsection Graphics Object Properties
@cindex graphics object properties

@menu
* Root Figure Properties::      
* Figure Properties::           
* Axes Properties::             
* Line Properties::             
* Text Properties::             
* Image Properties::            
* Patch Properties::            
* Surface Properties::          
@end menu

@node Root Figure Properties
@subsubsection Root Figure Properties

@table @code
@item currentfigure
Index to graphics object for the current figure.

@c FIXME -- does this work?
@c @item visible
@c Either @code{"on"} or @code{"off"} to toggle display of figures.
@end table

@node Figure Properties
@subsubsection Figure Properties
@cindex figure properties

@table @code
@item nextplot
May be one of
@table @code
@item "new"
@item "add"
@item "replace"
@item "replacechildren"
@end table

@item closerequestfcn
Handle of function to call when a figure is closed.

@item currentaxes
Index to graphics object of current axes.

@item colormap
An N-by-3 matrix containing the color map for the current axes.

@item visible
Either @code{"on"} or @code{"off"} to toggle display of the figure.

@item paperorientation
Indicates the orientation for printing.  Either @code{"landscape"} or
@code{"portrait"}.
@end table

@node Axes Properties
@subsubsection Axes Properties
@cindex axes properties

@table @code
@item position
A vector specifying the position of the plot, excluding titles, axes and
legend.  The four elements of the vector are the coordinates of the
lower left corner and width and height of the plot, in units normalized
to the width and height of the plot window.  For example, @code{[0.2,
0.3, 0.4, 0.5]} sets the lower left corner of the axes at @math{(0.2,
0.3)} and the width and height to be 0.4 and 0.5 respectively.  See also
the @code{outerposition} property.

@item title
Index of text object for the axes title.

@item box
Either @code{"on"} or @code{"off"} to toggle display of the box around
the axes.

@item key
Either @code{"on"} or @code{"off"} to toggle display of the legend.
Note that this property is not compatible with @sc{Matlab} and may be
removed in a future version of Octave.

@item keybox
Either @code{"on"} or @code{"off"} to toggle display of a box around the
legend.  Note that this property is not compatible with @sc{Matlab} and
may be removed in a future version of Octave.

@item keypos
An integer from 1 to 4 specifying the position of the legend.  1
indicates upper right corner, 2 indicates upper left, 3 indicates lower
left, and 4 indicates lower right.  Note that this property is not
compatible with @sc{Matlab} and may be removed in a future version of
Octave.

@item dataaspectratio
A two-element vector specifying the relative height and width of the
data displayed in the axes.  Setting @code{dataaspectratio} to @samp{1,
2]} causes the length of one unit as displayed on the y axis to be the
same as the length of 2 units on the x axis.  Setting
@code{dataaspectratio} also forces the @code{dataaspectratiomode}
property to be set to @code{"manual"}.

@item dataaspectratiomode
Either @code{"manual"} or @code{"auto"}.

@item xlim
@itemx ylim
@itemx zlim
@itemx clim
Two-element vectors defining the limits for the x, y, and z axes and the 
Setting one of these properties also forces the corresponding mode
property to be set to @code{"manual"}.

@item xlimmode
@itemx ylimmode
@itemx zlimmode
@itemx climmode
Either @code{"manual"} or @code{"auto"}.

@item xlabel
@itemx ylabel
@itemx zlabel
Indices to text objects for the axes labels.

@item xgrid
@itemx ygrid
@itemx zgrid
Either @code{"on"} or @code{"off"} to toggle display of grid lines.

@item xminorgrid
@itemx yminorgrid
@itemx zminorgrid
Either @code{"on"} or @code{"off"} to toggle display of minor grid lines.

@item xtick
@itemx ytick
@itemx ztick
Setting one of these properties also forces the corresponding mode
property to be set to @code{"manual"}.

@item xtickmode
@itemx ytickmode
@itemx ztickmode
Either @code{"manual"} or @code{"auto"}.

@item xticklabel
@itemx yticklabel
@itemx zticklabel
Setting one of these properties also forces the corresponding mode
property to be set to @code{"manual"}.

@item xticklabelmode
@itemx yticklabelmode
@itemx zticklabelmode
Either @code{"manual"} or @code{"auto"}.

@item xscale
@itemx yscale
@itemx zscale
Either @code{"linear"} or @code{"log"}.

@item xdir
@itemx ydir
@itemx zdir
Either @code{"forward"} or @code{"reverse"}.

@item xaxislocation
@itemx yaxislocation
Either @code{"top"} or @code{"bottom"} for the x axis and @code{"left"}
or @code{"right"} for the y axis.

@item view
A three element vector specifying the view point for three-dimensional plots.

@item visible
Either @code{"on"} or @code{"off"} to toggle display of the axes.

@item nextplot
May be one of
@table @code
@item "new"
@item "add"
@item "replace"
@item "replacechildren"
@end table

@item outerposition
A vector specifying the position of the plot, including titles, axes and
legend.  The four elements of the vector are the coordinates of the
lower left corner and width and height of the plot, in units normalized
to the width and height of the plot window.  For example, @code{[0.2,
0.3, 0.4, 0.5]} sets the lower left corner of the axes at @math{(0.2,
0.3)} and the width and height to be 0.4 and 0.5 respectively.  See also
the @code{position} property.
@end table

@node Line Properties
@subsubsection Line Properties
@cindex line properties

@table @code
@itemx xdata
@itemx ydata
@itemx zdata
@itemx ldata
@itemx udata
@itemx xldata
@itemx xudata
The data to be plotted.  The @code{ldata} and @code{udata} elements are
for errorbars in the y direction, and the @code{xldata} and @code{xudata}
elements are for errorbars in the x direction.

@item color
The RGB color of the line, or a color name.  @xref{Colors}.

@item linestyle
@itemx linewidth
@xref{Line Styles}.

@item marker
@item markeredgecolor
@item markerfacecolor
@item markersize
@xref{Marker Styles}.

@item keylabel
The text of the legend entry corresponding to this line.  Note that this
property is not compatible with @sc{Matlab} and may be removed in a
future version of Octave.
@end table

@node Text Properties
@subsubsection Text Properties
@cindex text properties

@table @code
@item string
The character string contained by the text object.

@item units
May be @code{"normalized"} or @code{"graph"}.

@item position
The coordinates of the text object.

@item rotation
The angle of rotation for the displayed text, measured in degrees.

@item horizontalalignment
May be @code{"left"}, @code{"center"}, or @code{"right"}.

@item color
The color of the text.  @xref{Colors}.

@item fontname
The font used for the text.

@item fontsize
The size of the font, in points to use.

@item fontangle
Flag whether the font is italic or normal. Valid values are 'normal',
'italic' and 'oblique'.

@item fontweight
Flag whether the font is bold, etc. Valid values are 'normal', 'bold',
'demi' or 'light'.

@item interpreter
Determines how the text is rendered. Valid values are 'none', 'tex' or
'latex'.
@end table

All text objects, including titles, labels, legends, and text, include
the property 'interpreter', this property determines the manner in which
special control sequences in the text are rendered. If the interpreter
is set to 'none', then no rendering occurs. At this point the 'latex'
option is not implemented and so the 'latex' interpreter also does not
interpret the text.

The 'tex' option implements a subset of @sc{TeX} functionality in the
rendering of the text. This allows the insertion of special characters
such as Greek or mathematical symbols within the text. The special
characters are also inserted with a code starting with the back-slash
(\) character, as in the table @ref{tab:extended}. 

In addition, the formatting of the text can be changed within the string
with the codes 

@multitable @columnfractions .2 .2 .6 .2
@item @tab \bf @tab Bold font @tab
@item @tab \it @tab Italic font @tab
@item @tab \sl @tab Oblique Font @tab
@item @tab \rm @tab Normal font @tab
@end multitable

These are be used in conjunction with the @{ and @} characters to limit
the change in the font to part of the string. For example

@example
xlabel ('@{\bf H@} = a @{\bf V@}')
@end example

where the character 'a' will not appear in a bold font. Note that to
avoid having Octave interpret the backslash characters in the strings,
the strings should be in single quotes.

It is also possible to change the fontname and size within the text 

@multitable @columnfractions .1 .4 .6 .1
@item @tab \fontname@{@var{fontname}@} @tab Specify the font to use @tab
@item @tab \fontsize@{@var{size}@} @tab Specify the size of the font to
use @tab
@end multitable

Finally, the superscript and subscripting can be controlled with the '^'
and '_' characters. If the '^' or '_' is followed by a @{ character,
then all of the block surrounded by the @{ @} pair is super- or
sub-scripted. Without the @{ @} pair, only the character immediately
following the '^' or '_' is super- or sub-scripted.

@float Table,tab:extended
@iftex
@tex
\vskip 6pt
{\hbox to \hsize {\hfill\vbox{\offinterlineskip \tabskip=0pt 
\halign{
\vrule height2.0ex depth1.ex width 0.6pt #\tabskip=0.3em &
# \hfil & \vrule # & # \hfil & # \vrule &
# \hfil & \vrule # & # \hfil & # \vrule &
# \hfil & \vrule # & # \hfil & # \vrule 
width 0.6pt \tabskip=0pt\cr
\noalign{\hrule height 0.6pt}
& Code && Sym && Code && Sym && Code && Sym &\cr
\noalign{\hrule}
& $\backslash$forall    && $\forall$ 
&& $\backslash$exists   && $\exists$ 
&& $\backslash$ni       && $\ni$       &\cr
& $\backslash$cong      && $\cong$ 
&& $\backslash$Delta    && $\Delta$ 
&& $\backslash$Phi      && $\Phi$      &\cr
& $\backslash$Gamma     && $\Gamma$ 
&& $\backslash$vartheta && $\vartheta$ 
&& $\backslash$Lambda   && $\Lambda$   &\cr
& $\backslash$Pi        && $\Pi$ 
&& $\backslash$Theta    && $\Theta$ 
&& $\backslash$Sigma    && $\Sigma$    &\cr
& $\backslash$varsigma  && $\varsigma$ 
&& $\backslash$Omega    && $\Omega$ 
&& $\backslash$Xi       && $\Xi$       &\cr
& $\backslash$Psi       && $\Psi$ 
&& $\backslash$perp     && $\perp$ 
&& $\backslash$alpha    && $\alpha$    &\cr
& $\backslash$beta      && $\beta$ 
&& $\backslash$chi      && $\chi$ 
&& $\backslash$delta    && $\delta$    &\cr
& $\backslash$epsilon   && $\epsilon$ 
&& $\backslash$phi      && $\phi$ 
&& $\backslash$gamma    && $\gamma$    &\cr
& $\backslash$eta       && $\eta$ 
&& $\backslash$iota     && $\iota$ 
&& $\backslash$varphi   && $\varphi$   &\cr
& $\backslash$kappa     && $\kappa$ 
&& $\backslash$lambda   && $\lambda$ 
&& $\backslash$mu       && $\mu$       &\cr
& $\backslash$nu        && $\nu$ 
&& $\backslash$o        && $\o$ 
&& $\backslash$pi       && $\pi$       &\cr
& $\backslash$theta     && $\theta$ 
&& $\backslash$rho      && $\rho$ 
&& $\backslash$sigma    && $\sigma$    &\cr
& $\backslash$tau       && $\tau$
&& $\backslash$upsilon  && $\upsilon$ 
&& $\backslash$varpi    && $\varpi$    &\cr
& $\backslash$omega     && $\omega$ 
&& $\backslash$xi       && $\xi$ 
&& $\backslash$psi      && $\psi$      &\cr
& $\backslash$zeta      && $\zeta$ 
&& $\backslash$sim      && $\sim$ 
&& $\backslash$Upsilon  && $\Upsilon$  &\cr
& $\backslash$prime     && $\prime$ 
&& $\backslash$leq      && $\leq$ 
&& $\backslash$infty    && $\infty$    &\cr
& $\backslash$clubsuit  && $\clubsuit$ 
&& $\backslash$diamondsuit    && $\diamondsuit$ 
&& $\backslash$heartsuit      && $\heartsuit$     &\cr
& $\backslash$spadesuit       && $\spadesuit$ 
&& $\backslash$leftrightarrow && $\leftrightarrow$ 
&& $\backslash$leftarrow      && $\leftarrow$     &\cr
& $\backslash$uparrow         && $\uparrow$ 
&& $\backslash$rightarrow     && $\rightarrow$ 
&& $\backslash$downarrow      && $\downarrow$     &\cr
& $\backslash$circ      && $\circ$ 
&& $\backslash$pm       && $\pm$ 
&& $\backslash$geq      && $\geq$      &\cr
& $\backslash$times     && $\times$ 
&& $\backslash$propto   && $\propto$ 
&& $\backslash$partial  && $\partial$  &\cr
& $\backslash$bullet    && $\bullet$
&& $\backslash$div      && $\div$ 
&& $\backslash$neq      && $\neq$      &\cr
& $\backslash$equiv     && $\equiv$ 
&& $\backslash$approx   && $\approx$ 
&& $\backslash$ldots    && $\ldots$ &\cr
& $\backslash$mid       && $\mid$ 
&& $\backslash$aleph    && $\aleph$ 
&& $\backslash$Im       && $\Im$ &\cr
& $\backslash$Re        && $\Re$ 
&& $\backslash$wp       && $\wp$ 
&& $\backslash$otimes   && $\otimes$ &\cr
& $\backslash$oplus     && $\oplus$ 
&& $\backslash$oslash   && $\oslash$ 
&& $\backslash$cap      && $\cap$ &\cr
& $\backslash$cup       && $\cup$ 
&& $\backslash$supset   && $\supset$ 
&& $\backslash$supseteq && $\supseteq$ &\cr
& $\backslash$subset    && $\subset$ 
&& $\backslash$subseteq && $\subseteq$ 
&& $\backslash$in       && $\in$ &\cr
& $\backslash$notin     && $\notin$
&& $\backslash$angle    && $\angle$
&& $\backslash$bigtriangledown && $\bigtriangledown$ &\cr
& $\backslash$langle    && $\langle$ 
&& $\backslash$rangle   && $\rangle$ 
&& $\backslash$nabla    && $\nabla$    &\cr
& $\backslash$prod      && $\prod$
&& $\backslash$surd     && $\surd$ 
&& $\backslash$cdot     && $\cdot$     &\cr
& $\backslash$neg       && $\neg$ 
&& $\backslash$wedge    && $\wedge$ 
&& $\backslash$vee      && $\vee$      &\cr
& $\backslash$Leftrightarrow && $\Leftrightarrow$
&& $\backslash$Leftarrow     && $\Leftarrow$
&& $\backslash$Uparrow       && $\Uparrow$           &\cr
& $\backslash$Rightarrow     && $\Rightarrow$
&& $\backslash$Downarrow     && $\Downarrow$
&& $\backslash$diamond  && $\diamond$  &\cr
& $\backslash$copyright && $\copyright$ 
&& $\backslash$rfloor   && $\rfloor$ 
&& $\backslash$lceil    && $\lceil$    &\cr
& $\backslash$lfloor    && $\lfloor$ 
&& $\backslash$rceil    && $\rceil$ 
&& $\backslash$int      && $\int$      &\cr
\noalign{\hrule height 0.6pt}
}}\hfill}}
@end tex
@end iftex
@ifnottex
@multitable @columnfractions .125 .25 .25 .25 .125
@item @tab  \forall     @tab  \exists     @tab  \ni      @tab
@item @tab  \cong       @tab  \Delta      @tab  \Phi     @tab
@item @tab  \Gamma      @tab  \vartheta   @tab  \Lambda  @tab
@item @tab  \Pi         @tab  \Theta      @tab  \Sigma   @tab
@item @tab  \varsigma   @tab  \Omega      @tab  \Xi      @tab
@item @tab  \Psi        @tab  \perp       @tab  \alpha   @tab
@item @tab  \beta       @tab  \chi        @tab  \delta   @tab  
@item @tab  \epsilon    @tab  \phi        @tab  \gamma   @tab
@item @tab  \eta        @tab  \iota       @tab  \varphi  @tab
@item @tab  \kappa      @tab  \lambda     @tab  \mu      @tab 
@item @tab  \nu         @tab  \o          @tab  \pi      @tab
@item @tab  \theta      @tab  \rho        @tab  \sigma   @tab 
@item @tab  \tau        @tab  \upsilon    @tab  \varpi   @tab
@item @tab  \omega      @tab  \xi         @tab  \psi     @tab 
@item @tab  \zeta       @tab  \sim        @tab  \Upsilon @tab
@item @tab  \prime      @tab  \leq        @tab  \infty   @tab
@item @tab  \clubsuit   @tab  \diamondsuit    @tab  \heartsuit  @tab
@item @tab  \spadesuit  @tab  \leftrightarrow @tab  \leftarrow  @tab 
@item @tab  \uparrow    @tab  \rightarrow @tab  \downarrow @tab 
@item @tab  \circ       @tab \pm          @tab  \geq     @tab 
@item @tab  \times      @tab  \propto     @tab  \partial @tab
@item @tab  \bullet     @tab \div         @tab  \neq     @tab 
@item @tab  \equiv      @tab  \approx     @tab  \ldots   @tab 
@item @tab  \mid        @tab  \aleph      @tab  \Im      @tab 
@item @tab  \Re         @tab \wp          @tab  \otimes  @tab
@item @tab  \oplus      @tab \oslash      @tab  \cap     @tab 
@item @tab  \cup        @tab   \supset    @tab  \supseteq @tab 
@item @tab  \subset     @tab \subseteq    @tab  \in      @tab 
@item @tab  \notin      @tab \angle       @tab  \bigrightriangledown @tab
@item @tab  \langle     @tab  \rangle     @tab  \nabla   @tab
@item @tab  \prod       @tab \surd        @tab  \cdot    @tab 
@item @tab  \neg        @tab  \wedge      @tab \vee      @tab 
@item @tab  \Leftrightarrow @tab \Leftarrow @tab \Uparrow @tab
@item @tab  \Rightarrow @tab \Downarrow   @tab \diamond  @tab
@item @tab  \copyright  @tab  \lfloor     @tab  \lceil   @tab 
@item @tab  \rfloor     @tab  \rceil      @tab  \int     @tab 
@end multitable
@end ifnottex
@caption{Available special characters in @sc{TeX} mode}
@end float

A complete example showing the capabilities of the extended text is

@example
@group
x = 0:0.01:3;
plot(x,erf(x));
hold on;
plot(x,x,"r");
axis([0, 3, 0, 1]);
text(0.65, 0.6175, strcat('\leftarrow x = @{2/\surd\pi',
' @{\fontsize@{16@}\int_@{\fontsize@{8@}0@}^@{\fontsize@{8@}x@}@}',
' e^@{-t^2@} dt@} = 0.6175'))
@end group
@end example

@ifnotinfo
@noindent
The result of which can be seen in @ref{fig:extendedtext}

@float Figure,fig:extendedtext
@image{extended,8cm}
@caption{Example of inclusion of text with the @sc{TeX} interpreter}
@end float
@end ifnotinfo

@node Image Properties
@subsubsection Image Properties
@cindex image properties

@table @code
@item cdata
The data for the image.  Each pixel of the image corresponds to an
element of @code{cdata}.  The value of an element of @code{cdata}
specifies the row-index into the colormap of the axes object containing
the image.  The color value found in the color map for the given index
determines the color of the pixel.

@item xdata
@itemx ydata
Two-element vectors specifying the range of the x- and y- coordinates for
the image.
@end table

@node Patch Properties
@subsubsection Patch Properties
@cindex patch properties

@table @code
@item cdata
@itemx xdata
@itemx ydata
@itemx zdata
Data defining the patch object.

@item facecolor
The fill color of the patch.  @xref{Colors}.

@item facealpha
A number in the range [0, 1] indicating the transparency of the patch.

@item edgecolor
The color of the line defining the patch.  @xref{Colors}.

@item linestyle
@itemx linewidth
@xref{Line Styles}.

@item marker
@itemx markeredgecolor
@itemx markerfacecolor
@itemx markersize
@xref{Marker Styles}.
@end table

@node Surface Properties
@subsubsection Surface Properties
@cindex surface properties

@table @code
@item xdata
@itemx ydata
@itemx zdata
The data determining the surface.  The @code{xdata} and @code{ydata}
elements are vectors and @code{zdata} must be a matrix.

@item keylabel
The text of the legend entry corresponding to this surface.  Note that
this property is not compatible with @sc{Matlab} and may be removed in a
future version of Octave.
@end table

@node Managing Default Properties
@subsection Managing Default Properties
@cindex default graphics properties
@cindex graphics properties, default

Object properties have two classes of default values, @dfn{factory
defaults} (the initial values) and @dfn{user-defined defaults}, which
may override the factory defaults.

Although default values may be set for any object, they are set in
parent objects and apply to child objects.  For example,

@example
set (0, "defaultlinecolor", "green");
@end example

@noindent
sets the default line color for all objects.  The rule for constructing
the property name to set a default value is

@example
default + @var{object-type} + @var{property-name}
@end example

This rule can lead to some strange looking names, for example
@code{defaultlinelinewidth"} specifies the default @code{linewidth}
property for @code{line} objects.

The example above used the root figure object, 0, so the default
property value will apply to all line objects.  However, default values
are hierarchical, so defaults set in a figure objects override those
set in the root figure object.  Likewise, defaults set in axes objects
override those set in figure or root figure objects.  For example,

@example
@group
subplot (2, 1, 1);
set (0, "defaultlinecolor", "red");
set (1, "defaultlinecolor", "green");
set (gca (), "defaultlinecolor", "blue");
line (1:10, rand (1, 10));
subplot (2, 1, 2);
line (1:10, rand (1, 10));
figure (2)
line (1:10, rand (1, 10));
@end group
@end example

@noindent
produces two figures.  The line in first subplot window of the first
figure is blue because it inherits its color from its parent axes
object.  The line in the second subplot window of the first figure is
green because it inherits its color from its parent figure object.  The
line in the second figure window is red because it inherits its color
from the global root figure parent object.

To remove a user-defined default setting, set the default property to
the value @code{"remove"}.  For example,

@example
set (gca (), "defaultlinecolor", "remove");
@end example

@noindent
removes the user-defined default line color setting from the current axes
object.

Getting the @code{"default"} property of an object returns a list of
user-defined defaults set for the object.  For example,

@example
get (gca (), "default");
@end example

@noindent
returns a list of user-defined default values for the current axes
object.

Factory default values are stored in the root figure object.  The
command

@example
get (0, "factory");
@end example

@noindent
returns a list of factory defaults.

@node Colors
@subsection Colors
@cindex graphics colors
@cindex colors, graphics

Colors may be specified as RGB triplets with values ranging from zero to
one, or by name.  Recognized color names include @code{"blue"},
@code{"black"}, @code{"cyan"}, @code{"green"}, @code{"magenta"},
@code{"red"}, @code{"white"}, and @code{"yellow"}.

@node Line Styles
@subsection Line Styles
@cindex line styles, graphics
@cindex graphics line styles

Line styles are specified by the following properties:

@table @code
@item linestyle
May be one of
@table @code
@item "-"
Solid lines.
@item "--"
Dashed lines.
@item ":"
Points.
@item "-."
A dash-dot line.
@end table

@item linewidth
A number specifying the width of the line.  The default is 1.  A value
of 2 is twice as wide as the default, etc.
@end table

@node Marker Styles
@subsection Marker Styles
@cindex graphics marker styles
@cindex marker styles, graphics

Marker styles are specified by the following properties:
@table @code
@item marker
A character indicating a plot marker to be place at each data point, or
@code{"none"}, meaning no markers should be displayed.

@itemx markeredgecolor
The color of the edge around the marker, or @code{"auto"}, meaning that
the edge color is the same as the face color.  @xref{Colors}.

@itemx markerfacecolor
The color of the marker, or @code{"none"} to indicate that the marker
should not be filled.  @xref{Colors}.

@itemx markersize
A number specifying the size of the marker.  The default is 1.  A value
of 2 is twice as large as the default, etc.
@end table

@node Interaction with gnuplot
@subsection Interaction with @code{gnuplot}

@anchor{doc-gnuplot_binary}
@deftypefn {Loadable Function} {@var{val} =} gnuplot_binary ()
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_binary (@var{new_val})
Query or set the name of the program invoked by the plot command.
The default value @code{"gnuplot"}.  @xref{Installation}.
@end deftypefn


@anchor{doc-gnuplot_use_title_option}
@deftypefn {Loadable Function} {@var{val} =} gnuplot_use_title_option ()
@deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_use_title_option (@var{new_val})
If enabled, append @samp{-title "Figure NN"} to the gnuplot command.
By default, this feature is enabled if the @code{DISPLAY} environment
variable is set when Octave starts.

@strong{This function is obsolete and will be removed from a future version
of Octave.}
@end deftypefn

