## Documentation Center |

Bivariate histogram

`hist3(X)hist3(X,nbins)hist3(X,ctrs)hist3(X,'Edges',edges)N = hist3(X,...)[N,C] = hist3(X,...)hist3(...,`

`hist3(X)` bins the elements of the *m*-by-2
matrix `X` into a 10-by-10 grid of equally spaced
containers, and plots a histogram. Each column of ** X** corresponds
to one dimension in the bin grid.

`hist3(X,nbins)` plots a histogram using
an `nbins(1)`-by-`nbins(2)` grid
of bins. `hist3(X,'Nbins',nbins)` is equivalent to `hist3(X,nbins)`.

`hist3(X,ctrs)`, where `ctrs` is
a two-element cell array of numeric vectors with monotonically non-decreasing
values, uses a 2-D grid of bins centered on `ctrs{1}` in
the first dimension and on `ctrs{2}` in the second. `hist3` assigns
rows of `X` falling outside the range of that grid
to the bins along the outer edges of the grid, and ignores rows of `X` containing `NaN`s. `hist3(X,'Ctrs',ctrs)` is
equivalent to `hist3(X,ctrs)`.

`hist3(X,'Edges',edges)`, where `edges` is
a two-element cell array of numeric vectors with monotonically non-decreasing
values, uses a 2-D grid of bins with edges at `edges{1}` in
the first dimension and at `edges{2}` in the second.
The (*i*, *j*)th bin includes the
value `X(k,:)` if

edges{1}(i) <= X(k,1) < edges{1}(i+1) edges{2}(j) <= X(k,2) < edges{2}(j+1)

Rows of `X` that fall on the upper edges of
the grid, `edges{1}(end)` or `edges{2}(end)`,
are counted in the `(I,j)`th or `(i,J)`th
bins, where `I` and `J` are the
lengths of `edges{1}` and `edges{2}`. `hist3` does
not count rows of `X` falling outside the range of
the grid. Use `-Inf` and `Inf` in `edges` to
include all non-`NaN` values.

`N = hist3(X,...)` returns a matrix containing
the number of elements of `X` that fall in each bin
of the grid, and does not plot the histogram.

`[N,C] = hist3(X,...)` returns the positions
of the bin centers in a 1-by-2 cell array of numeric vectors, and
does not plot the histogram. `hist3(ax,X,...)` plots
onto an `axes` with handle `ax` instead
of the current `axes`. See the `axes` reference page for more information
about handles to plots.

`hist3(...,param1,val1,param2,val2,...)` allows
you to specify graphics parameter name/value pairs to fine-tune the
plot.

`accumarray` | `bar` | `bar3` | `hist` | `histc`

Was this topic helpful?