Histogram plot
Histograms are a type of bar plot for numeric data that group the data into
bins. After you create a Histogram
object, you can modify aspects of
the histogram by changing its property values. This is particularly useful for quickly
modifying the properties of the bins or changing the display.
histogram(
creates a histogram
plot of X
)X
. The histogram
function uses
an automatic binning algorithm that returns bins with a uniform width,
chosen to cover the range of elements in X
and reveal the
underlying shape of the distribution. histogram
displays the bins as rectangles such that the height of each rectangle
indicates the number of elements in the bin.
histogram(
, where
C
)C
is a categorical array, plots a histogram with a
bar for each category in C
.
histogram(
plots only the subset of categories specified by
C
,Categories
)Categories
.
histogram('Categories',
manually specifies categories and associated bin counts.
Categories
,'BinCounts',counts
)histogram
plots the specified bin counts and does
not do any data binning.
histogram(___,
specifies additional options with one or more Name,Value
)Name,Value
pair arguments using any of the previous syntaxes. For example, you can
specify 'BinWidth'
and a scalar to adjust the width of
the bins, or 'Normalization'
with a valid option
('count'
, 'probability'
,
'countdensity'
, 'pdf'
,
'cumcount'
, or 'cdf'
) to use a
different type of normalization. For a list of properties, see Histogram Properties.
histogram(
plots into the axes specified by ax
,___)ax
instead of into the
current axes (gca
). The option ax
can
precede any of the input argument combinations in the previous
syntaxes.
returns a h
= histogram(___)Histogram
object. Use this to inspect and
adjust the properties of the histogram. For a list of properties, see
Histogram Properties.
Histogram Properties | Histogram appearance and behavior |
Histogram plots created using histogram
have a context menu
in plot edit mode that enables interactive manipulations in the figure window.
For example, you can use the context menu to interactively change the number of
bins, align multiple histograms, or change the display order.
When you add data tips to a histogram plot, they display the bin edges and bin count.
discretize
| fewerbins
| histcounts
| histcounts2
| Histogram Properties | histogram2
| morebins