Label each data point and color code the data points

Hello,
I have an XY scatter plot of 49 points, and I want to label each point according to a text. There are three classes of text (A, B and C) , and I would like to add the class to each point, and color code them for A, B and C. for example, for the first five datapoints:
X=[1 2 3 4 5]; Y= [2 4 6 8 10], and the labels would be [A A C B C]. I'd like to plot XY, with the datapoints colour coded acording to A, B and C., with a legend.
I looked up the documentation, and this is all I could find on multipoint text:
Text for Multiple Data Points
To display the same text at each location, specify txt as a character vector or string. For example, text([0 1],[0 1],'my text').
To display different text at each location, use a cell array. For example, text([0 1],[0 1],{'first','second'}).
For multiline text, use nested cell arrays. For example, text([0 1],[0 1],{{'first','new line'},'second'})
However, it wasn't quite clear to me how to apply this to my data. Could you help me with this please?
Thank you!

답변 (1개)

Kevin Joshi
Kevin Joshi 2020년 6월 9일

0 개 추천

You can use the following function to colour code groups (class) in scatter plot
To label each point use the text command,
https://in.mathworks.com/help/matlab/ref/text.html

댓글 수: 1

Thanks Kevin; though these links were not that helpful for me.

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

카테고리

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

태그

질문:

2020년 6월 9일

댓글:

2020년 6월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by