Showing repeat data points in XY/scatter plot

I'm trying to figure out a way to show in a scatter plot a way to make points darker or larger if they appear more than once. Lets say you have 3 points, and 2 are the exact same x,y coordinates, but plotting this you would only see 2 points that look the same on the plot. How can the ones that are repeats look different? I was trying to write a function to make new arrays with repeat data, but this is proving difficult as well.

 채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 3일

1 개 추천

%Data
x = ones(1,12);
y = [1 1 2 3 3 3 4 5 6 2 2 2];
%Engine
[uxy, jnk, idx] = unique([x.',y.'],'rows');
szscale = histc(idx,unique(idx));
%Plot Scale of 25 and stars
scatter(uxy(:,1),uxy(:,2),'p','sizedata',szscale*25)

댓글 수: 1

This is fine for integer coordinates; if the coordinates have fractions, then the fuller accumarray() solution I linked to would be necessary.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 6월 3일

0 개 추천

Please see my answer to this. Be sure to expand the comments as the details show up there.

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

Ken
2011년 6월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by