%% Specify Bin Edges of Histogram
% Generate 1,000 pairs of random numbers and create a bivariate histogram. Specify the bin edges using two vectors, with infinitely wide bins on the boundary of the histogram to capture all outliers that do not satisfy |x|< 2.

x = randn(1000,1);
y = randn(1000,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges)

% When the bin edges are infinite, histogram2 displays each outlier bin (along the boundary of the histogram) as being double the width of the bin next to it.
%
% Specify the Normalization property as 'countdensity' to remove the bins containing the outliers. Now the volume of each bin represents the frequency of observations in that interval.

h.Normalization = 'countdensity';

% Copyright 2015 The MathWorks, Inc.