Next: Three-Dimensional Plotting, Previous: Two-Dimensional Plotting, Up: Plotting

### 16.2 Specialized Two-Dimensional Plots

— Function File: h = bar (x, y, style)
— Function File: [xb, yb] = bar (...)

> Given two vectors of x-y data, `bar` produces a bar graph.

> 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 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 'group' (the default), or 'stack'.

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

>               bar (x, y);

> and

>               [xb, yb] = bar (x, y);
>               plot (xb, yb);

> are equivalent.

> See also: hbar, plot, semilogx, semilogy, loglog, polar, mesh, contour, stairs, xlabel, ylabel, title.

— Function File: c = contour (z)
— Function File: c = contour (z, vn)
— Function File: c = contour (x, y, z)
— Function File: c = contour (x, y, z, vn)

> 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. c is only returned if requested. For example:

>               x = 0:2;
>               y = x;
>               z = x' * y;
>               contour (x, y, z, 2:3)

> See also: contourc, line, plot.

— Function File: [c, lev] = contourc (x, y, z, vn)

> 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.

— Function File: hist (y, x, 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.

> 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.

— Function File: loglog (args)

> Make 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, semilogy, loglog, polar, mesh, contour, bar, stairs, xlabel, ylabel, title.

— Function File: polar (theta, rho, fmt)

> Make a two-dimensional plot given polar the coordinates theta and rho.

> The optional third argument specifies the line type.

> See also: plot, semilogx, semilogy, loglog, mesh, contour, bar, stairs, xlabel, ylabel, title.

— Function File: semilogx (args)

> Make 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, polar, mesh, contour, bar, stairs, xlabel, ylabel, title.

— Function File: semilogy (args)

> Make 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, polar, mesh, contour, bar, stairs, xlabel, ylabel, title.

— Function File: h = stem (x, y, linespec)

> 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 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 rows 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.

— Function File: stairs (x, y)

> Given two vectors of x-y data, bar produces a `stairstep' plot.

> 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.

— Function File: errorbar (args)

> 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 (See __pltopt__). 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, ">")

> xerrorbar plot of y versus x with x errorbars drawn from x-ex to x+ex.

>               errorbar(x, y1, ey, "~", x, y2, ly, uy)

> Two 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, "~>")

> xyerrorbar plot of y versus x where x errorbars are drawn from x-lx to x+ux and y errorbars from y-ly to y+uy.

> See also: semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__, bar, stairs, xlabel, ylabel, title.

— Function File: loglogerr (args)

> This function produces 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, polar, mesh, contour, __pltopt__, bar, stairs, xlabel, ylabel, title.

— Function File: semilogxerr (args)

> This function produces 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, polar, mesh, contour, __pltopt__, bar, stairs, xlabel, ylabel, title.

— Function File: semilogyerr (args)

> This function produces 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, polar, mesh, contour, __pltopt__, bar, stairs, xlabel, ylabel, title.