%% Adjust Properties of Histogram2 Object
% This example creates a histogram2 object, and then shows how to adjust the properties of the histogram to affect the output display.
% Generate 1,000 random numbers in each dimension and create a bivariate histogram.

x = randn(1000,1);
y = randn(1000,1);
h = histogram2(x,y)

%
% Change the normalization of the histogram by setting the Normalization property to 'probability'.

h.Normalization = 'probability';

%
% Change the bin limits in each dimension so that -5 \le x \le 5 and -2 \le y \le 2. When you set XBinLimits or YBinLimits, the XBinLimitsMode or YBinLimitsMode property automatically changes to 'manual'.

h.XBinLimits = [-5 5];
h.YBinLimits = [-2 2];

%
% Show the empty bins.

h.ShowEmptyBins = 'on';

%
% Change the display style to show tiles. Switch to a 2-D view.

h.DisplayStyle = 'tile';
view(2)

% Copyright 2015 The MathWorks, Inc.