MATLAB: Plot 2D-histogram for X and Y

histogramMATLABplot

Dear all,
I have two types of data sets (X and Y) with equal size, which I would like to plot 2D-histogram of them, in order to compare X by Y.
So the larger the scatter implies the greater
disagreement.
I used this script below:
data = [X,Y];
hist3(data,'CdataMode','auto')
xlabel('observed')
ylabel('modeled')
colorbar
view(2)
And here is my achievement:
Unfortunately, as you can see this plot does not represent my goal, for instance, please look at this figure below (I want to achieve a plot like this below):
So any suggestion is really helpful.
Thank you all

Best Answer

Try this:
D1 = load('X.mat');
D2 = load('Y.mat');
X = D1.X;
Y = D2.Y;
data = [X,Y];
hh3 = hist3(data, 'Nbins',[1 1]*60);
figure
image(flipud(hh3))
ax = gca;
xt = ax.XTick;
yt = ax.YTick;
ax.XTickLabel = xt*10;
set(ax, 'YTick',[0 yt], 'YTickLabel', [flip([0 yt])]*10)
producing:
Experiment to get different results.
.