histogram2
Create bivariate histogram plot.
📝Syntax
histogram2(X, Y)
histogram2(X, Y, nbins)
histogram2(X, Y, xedges, yedges)
histogram2(..., propertyName, propertyValue)
histogram2(ax, ...)
h = histogram2(...)
📥Input Arguments
Parameter Description
X x data values.
Y y data values with the same number of elements as X.
nbins number of bins, specified as a scalar or two-element vector.
xedges strictly increasing x bin edges.
yedges strictly increasing y bin edges.
propertyName histogram2 object property name.
propertyValue histogram2 object property value.
ax target axes object.
📤Output Arguments
Parameter Description
h histogram2 graphics object.
📄Description

histogram2 bins paired numeric data and displays the bin values as 3-D bars or a tiled surface.

See histogram2 properties for the complete property list.

💡Examples
x = [1 1 2 3 4 4];
y = [1 2 2 3 3 4];
histogram2(x, y, [0 2 4], [0 2 4]);
Example illustration
x = randn(400, 1);
y = 0.5 * x + randn(400, 1);
histogram2(x, y, [12 10], 'Normalization', 'probability');
Example illustration
x = [1 1 2 3 4 4];
y = [1 2 2 3 3 4];
h = histogram2(x, y, [0 2 4], [0 2 4], 'DisplayStyle', 'tile');
h.ShowEmptyBins = 'on';
Example illustration
🔗See Also
histogram2 propertieshistogramsurf
Edit this page on GitHub