MATLAB: Using Matlab to plot density contour for scatter plot

density contour for scatter plot

Hi guys, I'm trying to use Matlab to plot the density contour for the following scatter plot. The bins will be 1X1 box. Within my limited understanding the density contour should be indicated how many points fall into the bins(correct me if I'm wrong), but I still cannot find a way to do the density plot. Need some help to solve this problem. Thanks!

Best Answer

Scatter doesn't do any binning. It's showing each individual data element.
Perhaps this approach does what you want?
x = randn(1,1000);
y = randn(1,1000);
n = hist3([x', y']);
pcolor(n)