user3714919
user3714919

Reputation: 41

How to put each points in each bar

I would like to do a 2d histogram (using hist3), where each of my points that have the same x but not the same y, to be only in one bar. So inside each bar of the histogram I would like to have only the points that they have the same x but not the same ye. So in this case even if i change the bin size, i will have again inside a bar, the same number of points. Can someone help me to do it?

Upvotes: 0

Views: 41

Answers (1)

ASantosRibeiro
ASantosRibeiro

Reputation: 1257

this? Choose option 1 for same x and y. choose option 2 for same x but y can vary

%simulation
x=1:10;
y=1:10;
figure,

%code to be used
ctrs{1}=unique(x); % same x in each bar

%option 1
ctrs{2}=unique(y); % same y in each bar

%option 2
bins=10; % y bins from min to max
ctrs{2}=linspace(min(y),max(y),bins); % y bins from min to max

hist3([x;y]',ctrs)

Upvotes: 1

Related Questions