Navigation

Operators and Keywords

Function List:

C++ API

: hist (y)
: hist (y, x)
: hist (y, nbins)
: hist (y, x, norm)
: hist (…, prop, val, …)
: hist (hax, …)
: [nn, xx] = hist (…)

Produce histogram counts or plots.

With one vector input argument, y, 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, y, plot a histogram where each bin contains a bar per input column.

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

If scalar, the second argument, nbins, defines the number of bins.

If a third argument is provided, the histogram is normalized such that the sum of the bars is equal to norm.

Extreme values are lumped into the first and last bins.

The histogram’s appearance may be modified by specifying property/value pairs. For example the face and edge color may be modified.

hist (randn (1, 100), 25, "facecolor", "r", "edgecolor", "b");

The histogram’s colors also depend upon the current colormap.

hist (rand (10, 3));
colormap (summer ());

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

With two output arguments, produce the values nn (numbers of elements) and xx (bin centers) such that bar (xx, nn) will plot the histogram.

See also: histc, bar, pie, rose.

Package: octave