%% Adjust Binned Scatter Plot Properties
% Generate 1,000 random numbers and create a binned scatter plot. Return the Binscatter object to adjust properties of the plot without recreating the entire plot.

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

%
% Specify exactly how many bins to use in each direction.

h.NumBins = [20 30];

%
% Turn on the display of empty bins in the plot.

h.ShowEmptyBins = 'on';

%
% Specify the extent of the axes with the XLimits and YLimits properties. Then limit the bin limits in the x direction with a vector.

xlim(gca,h.XLimits); 
ylim(gca,h.YLimits); 
h.XLimits = [-1 1];

% Copyright 2012 The MathWorks, Inc.