%% Adjust Number of Histogram Bins
% Generate 1,000 pairs of random numbers and create a bivariate histogram.

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

%
% Use the morebins function to coarsely adjust the number of bins in the x dimension.

nbins = morebins(h,'x');
nbins = morebins(h,'x')

%
% Use the fewerbins function to adjust the number of bins in the y dimension.

nbins = fewerbins(h,'y');
nbins = fewerbins(h,'y')

%
% Adjust the number of bins at a fine grain level by explicitly setting the number of bins.

h.NumBins = [20 10];

% Copyright 2015 The MathWorks, Inc.