name a single point in a scatterplot

Hi, can anyone tell me how to name a single point in a scatterplot? I want to add name on the top of every dot to show that each dot represent different model. My data is a 2-d data. Thank you.

 채택된 답변

Walter Roberson
Walter Roberson 2012년 3월 7일

0 개 추천

text() the string at the position of the point.
Your plot would probably be less crowded if you were to use different dot colors for the different models.
You may wish to consider using datacursormode() to allow the user to select a point and have the model name show up.

댓글 수: 5

niclo
niclo 2012년 3월 7일
I tried to use text() but it only shows the value of my data which is number. What I need is insert name above the dots.
Walter Roberson
Walter Roberson 2012년 3월 7일
For example,
for K = 1 : length(x)
text(x(K),y(K), sprintf('Point #%d', K));
end
niclo
niclo 2012년 3월 7일
Sorry i am quite new in matlab.
If my x data is 11x1 double and y is 11 x 1 double. The name that i want to insert is : a e f s g j d e a f h. Can you show me how to use the loops that you shown?
Thank you.
Walter Roberson
Walter Roberson 2012년 3월 7일
names = {'a' 'e' 'f' 's' 'g' 'j' 'd' 'e' 'a' 'f' 'h'};
for K = 1 : length(x)
text(x(K), y(K), names{K});
end
niclo
niclo 2012년 3월 7일
Thanks a lot.This is exactly what I need. Really appreciate your help.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by