[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 Advanced Plotting.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The plot
function allows you to create simple x-y plots with
linear axes. For example,
x = -10:0.1:10; plot (x, sin (x)); |
displays a sine wave shown in fig:plot. On most systems, this command will open a separate plot window to display the graph.
Figure 15.1: Simple Two-Dimensional Plot.
The function 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,
fplot (@sin, [-10, 10], 201); |
produces a plot that is equivalent to the one above, but also includes a legend displaying the name of the plotted function.
Produces two-dimensional plots. Many different combinations of arguments are possible. The simplest form is
plot (y) |
where the argument is taken as the set of y coordinates and the 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 print
command.
If more than one argument is given, they are interpreted as
plot (y, property, value, …) |
or
plot (x, y, property, value, …) |
or
plot (x, y, fmt, …) |
and so on. Any number of argument sets may appear. The x and y values are interpreted as follows:
If both arguments are scalars, a single point is plotted.
Multiple property-value pairs may be specified, but they must appear
in pairs. These arguments are applied to the lines drawn by
plot
.
If the fmt argument is supplied, it is interpreted as follows. If fmt is missing, the default gnuplot line style is assumed.
Set lines plot style (default).
Set dots plot style.
Set impulses plot style.
Set steps plot style.
Interpreted as the plot color if n is an integer in the range 1 to 6.
If nm is a two digit integer and m is an integer in the
range 1 to 6, m is interpreted as the point style. This is only
valid in combination with the @
or -@
specifiers.
If c is one of "k"
(black), "r"
(red), "g"
(green), "b"
(blue), "m"
(magenta), "c"
(cyan),
or "w"
(white), it is interpreted as the line plot color.
Here "title"
is the label for the key.
Used in combination with the points or linespoints styles, set the point style.
The 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:
plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+") |
This command will plot y
with points of type 2 (displayed as
`+') and color 1 (red), y2
with lines, y3
with lines of
color 4 (magenta) and y4
with points displayed as `+'.
plot (b, "*", "markersize", 3) |
This command will plot the data in the variable b
,
with points displayed as `*' with a marker size of 3.
t = 0:0.1:6.3; plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"); |
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 gca
.
See also: semilogx, semilogy, loglog, polar, mesh, contour, bar,
stairs, errorbar, xlabel, ylabel, title, print.
Plot a function fn, within the defined limits. fn
an be either a string, a function handle or an inline function.
The limits of the plot are given by limits of the form
[xlo, xhi]
or [xlo, xhi,
ylo, yhi]
. tol is the default tolerance to use for the
plot, and if tol is an integer it is assumed that it defines the
number points to use in the plot. The fmt argument is passed
to the plot command.
fplot ("cos", [0, 2*pi]) fplot ("[cos(x), sin(x)]", [0, 2*pi]) |
See also: plot.
The functions semilogx
, semilogy
, and loglog
are
similar to the plot
function, but produce plots in which one or
both of the axes use log scales.
Produce a two-dimensional plot using a log scale for the x
axis. See the description of plot
for a description of the
arguments that semilogx
will accept.
See also: plot, semilogy, loglog.
Produce a two-dimensional plot using a log scale for the y
axis. See the description of plot
for a description of the
arguments that semilogy
will accept.
See also: plot, semilogx, loglog.
Produce a two-dimensional plot using log scales for both axes. See
the description of plot
for a description of the arguments
that loglog
will accept.
See also: plot, semilogx, semilogy.
The functions bar
, barh
, stairs
, and stem
are useful for displaying discrete data. For example,
hist (randn (10000, 1), 30); |
produces the histogram of 10,000 normally distributed random numbers shown in fig:hist.
Figure 15.2: Histogram.
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 w.
If y is a matrix, then each column of 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 style
argument, which can take the values "grouped"
(the default),
or "stacked"
.
The optional return value h provides a handle to the patch object. Whereas the option input handle h allows an axis handle to be passed. Properties of the patch graphics object can be changed using prop, val pairs.
See also: barh, plot.
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 w.
If y is a matrix, then each column of 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 style
argument, which can take the values "grouped"
(the default),
or "stacked"
.
The optional return value h provides a handle to the patch object. Whereas the option input handle h allows an axis handle to be passed. Properties of the patch graphics object can be changed using prop, val pairs.
See also: bar, plot.
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.
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 norm.
Extreme values are lumped in the first and last bins.
With two output arguments, produce the values nn and xx such
that bar (xx, nn)
will plot the histogram.
See also: bar.
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,
stairs (x, y); |
and
[xs, ys] = stairs (x, y); plot (xs, ys); |
are equivalent.
See also: plot, semilogx, semilogy, loglog, polar, mesh, contour,
bar, xlabel, ylabel, title.
Plot a stem graph and return the handles of the line and marker
objects used to draw the stems. The default color is "r"
(red). The default line style is "-"
and the default marker is
"o"
.
For example,
x = 1:10; stem (x); |
plots 10 stems with heights from 1 to 10;
x = 1:10; y = ones (1, length (x))*2.*x; stem (x, y); |
plots 10 stems with heights from 2 to 20;
x = 1:10; y = ones (size (x))*2.*x; h = stem (x, y, "b"); |
plots 10 bars with heights from 2 to 20 (the color is blue, and 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);
x = 1:10; y = ones (size (x))*2.*x; h = stem (x, y, "-.k"); |
plots 10 stems with heights from 2 to 20
(the color is black, line style is "-."
, and 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);
x = 1:10; y = ones (size (x))*2.*x; h = stem (x, y, "-.k."); |
plots 10 stems with heights from 2 to 20
(the color is black, line style is "-."
and the marker style
is "."
, and 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);
x = 1:10; y = ones (size (x))*2.*x; h = stem (x, y, "fill"); |
plots 10 stems with heights from 2 to 20
(the color is rgb-triple defined, the line style is "-"
,
the marker style is "o"
, and 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!
See also: bar, barh, plot.
The contour
and contourc
functions produce two-dimensional
contour plots from three dimensional data.
Plot level curves (contour lines) of the matrix z, using the
contour matrix c computed by contourc
from the same
arguments; see the latter for their interpretation. The set of
contour levels, c, is only returned if requested. For example:
x = 0:2; y = x; z = x' * y; contour (x, y, z, 2:3) |
The style to use for the plot can be defined with a line style style
in a similar manner to the line styles used with the plot
command.
Any markers defined by style are ignored.
The optional input and output argument h allows an axis handle to
be passed to contour
and the handles to the contour objects to be
returned.
See also: contourc, patch, plot.
Compute isolines (countour lines) of the matrix z. Parameters x, y and vn are optional.
The return value lev is a vector of the contour levels. The return value c is a 2 by n matrix containing the contour lines in the following format
c = [lev1, x1, x2, ..., levn, x1, x2, ... len1, y1, y2, ..., lenn, y1, y2, ...] |
in which contour line n has a level (height) of levn and length of lenn.
If x and y are omitted they are taken as the row/column
index of z. 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 vn = [val, val]
;
If vn is omitted it defaults to 10.
For example,
x = 0:2; y = x; z = x' * y; contourc (x, y, z, 2:3) ⇒ 2.0000 2.0000 1.0000 3.0000 1.5000 2.0000 2.0000 1.0000 2.0000 2.0000 2.0000 1.5000 |
See also: contour.
The errorbar
, semilogxerr
, semilogyerr
, and
loglogerr
functions produces plots with error bar markers. For
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); |
produces the figure shown in fig:errorbar.
Figure 15.3: Errorbar plot.
This function produces two-dimensional plots with errorbars. Many different combinations of arguments are possible. The simplest form is
errorbar (y, ey) |
where the first argument is taken as the set of y coordinates and the second argument ey is taken as the errors of the y values. 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
errorbar (x, y, …, fmt, …) |
where after x and y there can be up to four error parameters such as ey, ex, ly, uy etc., depending on the plot type. Any number of argument sets may appear, as long as they are separated with a format string fmt.
If y is a matrix, x and error parameters must also be matrices having same dimensions. The columns of y are plotted versus the corresponding columns of x and errorbars are drawn from the corresponding columns of error parameters.
If fmt is missing, yerrorbars ("~") plot style is assumed.
If the fmt argument is supplied, it is interpreted as in normal plots. In addition the following plot styles are supported by errorbar:
Set yerrorbars plot style (default).
Set xerrorbars plot style.
Set xyerrorbars plot style.
Set boxes plot style.
Set boxerrorbars plot style.
Set boxxyerrorbars plot style.
Examples:
errorbar (x, y, ex, ">") |
produces an xerrorbar plot of y versus x with x errorbars drawn from x-ex to x+ex.
errorbar (x, y1, ey, "~", x, y2, ly, uy) |
produces yerrorbar plots with y1 and y2 versus x. Errorbars for y1 are drawn from y1-ey to y1+ey, errorbars for y2 from y2-ly to y2+uy.
errorbar (x, y, lx, ux, ly, uy, "~>") |
produces an xyerrorbar plot of y versus x in which
x errorbars are drawn from x-lx to x+ux
and y errorbars from y-ly to y+uy.
See also: semilogxerr, semilogyerr, loglogerr.
Produce two-dimensional plots on a semilogarithm axis with errorbars. Many different combinations of arguments are possible. The most used form is
semilogxerr (x, y, ey, fmt) |
which produces a semi-logarithm plot of y versus x
with errors in the y-scale defined by ey and the plot
format defined by fmt. See errorbar for available formats and
additional information.
See also: errorbar, loglogerr semilogyerr.
Produce two-dimensional plots on a semilogarithm axis with errorbars. Many different combinations of arguments are possible. The most used form is
semilogyerr (x, y, ey, fmt) |
which produces a semi-logarithm plot of y versus x
with errors in the y-scale defined by ey and the plot
format defined by fmt. See errorbar for available formats and
additional information.
See also: errorbar, loglogerr semilogxerr.
Produce two-dimensional plots on double logarithm axis with errorbars. Many different combinations of arguments are possible. The most used form is
loglogerr (x, y, ey, fmt) |
which produces a double logarithm plot of y versus x
with errors in the y-scale defined by ey and the plot
format defined by fmt. See errorbar for available formats and
additional information.
See also: errorbar, semilogxerr, semilogyerr.
Finally, the polar
function allows you to easily plot data in
polar coordinates. However, the display coordinates remain rectangular
and linear. For example,
polar (0:0.1:10*pi, 0:0.1:10*pi); |
produces the spiral plot shown in fig:polar.
Figure 15.4: Polar plot.
Make a two-dimensional plot given the polar coordinates theta and rho.
The optional third argument specifies the line type.
See also: plot.
Produce a pie chart.
Called with a single vector arrgument, produces a pie chart of the elements in x, with the size of the slice determined by percentage size of the values of x.
The variable explode is a vector of the same length as x that if non zero 'explodes' the slice from the pie chart.
If given labels is a cell array of strings of the same length as x, giving the labels of each of the slices of the pie chart.
The optional return value h provides a handle to the patch object.
See also: bar, stem.
Plot the (u, v)
components of a vector field in
an (x, y)
meshgrid. If the grid is uniform, you can
specify x and y as vectors.
If x and y are undefined they are assumed to be
(1:m, 1:n)
where [m, n] =
size(u)
.
The variable 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 style
in a similar manner to the line styles used with the 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 h provides a list of handles to the the parts of the vector field (body, arrow and marker).
[x, y] = meshgrid (1:2:20); quiver (x, y, sin (2*pi*x/10), sin (2*pi*y/10)); |
See also: plot.
Density plot for given matrices x, and y from meshgrid
and
a matrix c corresponding to the x and y coordinates of
the mesh. If x and y are vectors, then a typical vertex
is (x(j), y(i), c(i,j)). Thus, columns of c
correspond to different x values and rows of c correspond
to different y values.
See also: meshgrid, contour.
Area plot of cummulative sum of the columns of y. This shows the
contributions of a value to a sum, and is functionally similar to
plot (x, cumsum (y, 2))
, except that the area under
the curve is shaded.
If the x argument is ommitted it is assumed to be given by
1 : rows (y)
. A value lvl can be defined that determines
where the base level of the shading under the curve should be defined.
Additional arguments to the area
function are passed to the
patch
. The optional return value h provides a handle to
the list of patch objects.
See also: plot, patch.
The axis function may be used to change the axis limits of an existing plot.
Set axis limits for plots.
The argument 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, axis
turns autoscaling on.
With one output argument, 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,
axis ([1, 2, 3, 4], "square"); |
forces a square aspect ratio, and
axis ("labely", "tic"); |
turns tic marks on for all axes and tic mark labels on for the y-axis only.
The following options control the aspect ratio of the axes.
"square"
Force a square aspect ratio.
"equal"
Force x distance to equal y-distance.
"normal"
Restore the balance.
The following options control the way axis limits are interpreted.
"auto"
Set the specified axes to have nice limits around the data or all if no axes are specified.
"manual"
Fix the current axes limits.
"tight"
Fix axes to the limits of the data (not implemented).
The option "image"
is equivalent to "tight"
and
"equal"
.
The following options affect the appearance of tic marks.
"on"
Turn tic marks and labels on for all axes.
"off"
Turn tic marks off for all axes.
"tic[xyz]"
Turn tic marks on for all axes, or turn them on for the specified axes and off for the remainder.
"label[xyz]"
Turn tic labels on for all axes, or turn them on for the specified axes and off for the remainder.
"nolabel"
Turn tic labels off for all axes.
Note, if there are no tic marks for an axis, there can be no labels.
The following options affect the direction of increasing values on the axes.
"ij"
Reverse y-axis, so lower values are nearer the top.
"xy"
Restore y-axis, so higher values are nearer the top.
If an axes handle is passed as the first argument, then operate on this axes rather than the current axes.
Similarly the axis limits of the colormap can be changed with the caxis function.
Set color axis limits for plots.
The argument 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 limits is 'auto', then automatic colormap scaling is applied, whereas if 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The function mesh
produces mesh surface plots. For example,
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); |
produces the familiar "sombrero" plot shown in fig:mesh. Note
the use of the function meshgrid
to create matrices of X and Y
coordinates to use for plotting the Z data. The ndgrid
function
is similar to meshgrid
, but works for N-dimensional matrices.
Figure 15.5: Mesh plot.
The meshc
function is similar to mesh
, but also produces a
plot of contours for the surface.
The plot3
function displays arbitrary three-dimensional data,
without requiring it to form a surface. For example
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); |
displays the spiral in three dimensions shown in fig:plot3.
Figure 15.6: Three dimensional spiral.
Finally, the view
function changes the viewpoint for
three-dimensional plots.
Plot a mesh given matrices x, and y from meshgrid
and
a matrix z corresponding to the x and y coordinates of
the mesh. If x and y are vectors, then a typical vertex
is (x(j), y(i), z(i,j)). Thus, columns of z
correspond to different x values and rows of z correspond
to different y values.
See also: meshgrid, contour.
Plot a mesh and contour given matrices x, and y from
meshgrid
and a matrix z corresponding to the x and
y coordinates of the mesh. If x and y are vectors,
then a typical vertex is (x(j), y(i), z(i,j)). Thus,
columns of z correspond to different x values and rows of
z correspond to different y values.
See also: meshgrid, mesh, contour.
Manipulation the mesh hidden line removal. Called with no argument
the hidden line removal is toggled. The argument mode can be either
'on' or 'off' and the set of the hidden line removal is set accordingly.
See also: mesh, meshc, surf.
Plot a surface given matrices x, and y from meshgrid
and
a matrix z corresponding to the x and y coordinates of
the mesh. If x and y are vectors, then a typical vertex
is (x(j), y(i), z(i,j)). Thus, columns of z
correspond to different x values and rows of z correspond
to different y values.
See also: mesh, surface.
Plot a surface and contour given matrices x, and y from
meshgrid
and a matrix z corresponding to the x and
y coordinates of the mesh. If x and y are vectors,
then a typical vertex is (x(j), y(i), z(i,j)). Thus,
columns of z correspond to different x values and rows of
z correspond to different y values.
See also: meshgrid, surf, contour.
Given vectors of x and y and z coordinates, and
returning 3 arguments, return three dimensional arrays corresponding
to the x, y, and z coordinates of a mesh. When
returning only 2 arguments, return matrices corresponding to the
x and y coordinates of a mesh. The rows of xx are
copies of x, and the columns of yy are copies of y.
If y is omitted, then it is assumed to be the same as x,
and z is assumed the same as y.
See also: mesh, contour.
Given n vectors x1, … xn, ndgrid
returns
n arrays of dimension n. The elements of the ith output argument
contains the elements of the vector xi repeated over all
dimensions different from the ith dimension. Calling ndgrid with
only one input argument x is equivalent of calling ndgrid with
all n input arguments equal to x:
[y1, y2, …, yn] = ndgrid (x, …, x)
See also: meshgrid.
Produce three-dimensional plots. Many different combinations of arguments are possible. The simplest form is
plot3 (x, y, z) |
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
plot3 (x, c) |
the real and imaginary parts of the second argument are used as the y and z coordinates, respectively.
If only one argument is given, as
plot3 (c) |
the real and imaginary parts of the argument are used as the y and z values, and they are plotted versus their index.
Arguments may also be given in groups of three as
plot3 (x1, y1, z1, x2, y2, z2, …) |
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
plot3 (x1, c1, "", c2, "", …) |
An example of the use of plot3
is
z = [0:0.05:5]; plot3 (cos(2*pi*z), sin(2*pi*z), z, ";helix;"); plot3 (z, exp(2i*pi*z), ";complex sinusoid;"); |
See also: plot.
Set or get the viewpoint for the current axes.
Set the shading of surface or patch graphic objects. Valid arguments
for type are "flat"
, "interp"
, or
"faceted"
. If ax is given the shading is applied to
axis ax instead of the current axis.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can add titles, axis labels, legends, and arbitrary text to an existing plot. For example,
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)"); |
The functions grid
and 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.
Create a title object and return a handle to it.
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 pos specifies the location of the legend as follows:
north |
center top | |
south |
center bottom | |
east |
right center | |
west |
left center | |
northeast |
right top (default) | |
northwest |
left top | |
southeast |
right bottom | |
southwest |
left bottom | |
outside |
can be appended to any location string |
Some specific functions are directly available using func:
Show legends from the plot
Hide legends from the plot
Draw a box around legends
Withdraw the box around legends
Text is to the left of the keys
Text is to the right of the keys
Create a text object with text label at position x, y, z on the current axes. Property-value pairs following label may be used to specify the appearance of the text.
Specify x, y, and z axis labels for the current figure. If h is
specified then label the axis defined by h.
See also: plot, semilogx, semilogy, loglog, polar, mesh, contour,
bar, stairs, ylabel, title.
Control the display of a border around the plot.
The argument may be either "on"
or "off"
. If it is
omitted, the current box state is toggled.
See also: grid.
Force the display of a grid on the plot.
The argument may be either "on"
or "off"
. If it is
omitted, the current grid state is toggled.
If arg is "minor"
then the minor grid is toggled. When
using a minor grid a second argument arg2 is allowed, which can
be either "on"
or "off"
to explicitly set the state of
the minor grid.
See also: plot.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Octave can display more than one plot in a single figure. The simplest
way to do this is to use the subplot
function to divide the plot
area into a series of subplot windows that are indexed by an integer.
For example,
subplot (2, 1, 1) fplot (@sin, [-10, 10]); subplot (2, 1, 2) fplot (@cos, [-10, 10]); |
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 subplot
is
numbered in column-major order (top to bottom, left to right).
Set up a plot grid with cols by rows subwindows and plot in location given by 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:
See also: plot.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can open multiple plot windows using the figure
function.
For example
figure (1); fplot (@sin, [-10, 10]); figure (2); fplot (@cos, [-10, 10]); |
creates two figures, with the first displaying a sine wave and the second a cosine wave. Figure numbers must be positive integers.
Set the current plot window to plot window 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The print
command allows you to save plots in a variety of
formats. For example,
print -deps foo.eps |
writes the current figure to an encapsulated PostScript file called `foo.eps'.
Print a graph, or save it to a file
filename defines the file name of the output file. If no filename is specified, output is sent to the printer.
options:
-Pprinter
Set the printer name to which the graph is sent if no filename is specified.
-color
-mono
Monochrome or colour lines.
-solid
-dashed
Solid or dashed lines.
-portrait
-landscape
Plot orientation, as returned by "orient".
-ddevice
Output device, where device is one of:
ps
ps2
psc
psc2
Postscript (level 1 and 2, mono and color)
eps
eps2
epsc
epsc2
Encapsulated postscript (level 1 and 2, mono and color)
tex
epslatex
epslatexstandalone
pstex
pslatex
Generate a LaTeX (or TeX) file for labels, and eps/ps for
graphics. The file produced by epslatexstandalone
can be
processed directly by LaTeX. The other formats are intended to
be included in a LaTeX (or TeX) document. The tex
device
is the same as the epslatex
device.
ill
aifm
Adobe Illustrator
cdr
corel
CorelDraw
dxf
AutoCAD
emf
Microsoft Enhanced Metafile
fig
XFig. If this format is selected the additional options
-textspecial
or -textnormal
can be used to control
whether the special flag should be set for the text in the figure
(default is -textnormal
).
hpgl
HP plotter language
mf
Metafont
png
Portable network graphics
pbm
PBMplus
svg
Scalable vector graphics
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.
-Sxsize,ysize
Plot size in pixels for PNG and SVG. If using the command form of
the print function, you must quote the xsize,ysize
option. For example, by writing "-S640,480"
.
-Ffontname
-Ffontname:size
-F:size
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'. size is given in points. fontname is ignored for the fig device.
The filename and options can be given in any order.
Set the default print orientation. Valid values for
orientation include "landscape"
and "portrait"
.
If called with no arguments, return the default print orientation.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The functions sombrero
and peaks
provide a way to check
that plotting is working. Typing either sombrero
or peaks
at the Octave prompt should display a three dimensional plot.
Produce the familiar three-dimensional sombrero plot using n grid lines. If n is omitted, a value of 41 is assumed.
The function plotted is
z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2)) |
See also: surf, meshgrid, mesh.
Generate a function with lots of local maxima and minima. The function has the form
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)
Called without a return argument, peaks
plots the surface of the
above function using mesh
. If n is a scalar, the peaks
returns the values of the above function on a n-by-n mesh over
the range [-3,3]
. The default value for n is 49.
If n is a vector, then it represents the x and y values
of the grid on which to calculate the above function. The x and
y values can be specified separately.
See also: surf, mesh, meshgrid.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on December, 26 2007 using texi2html 1.76.