Label each data point and color code the data points
29 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Kevin Joshi
2020-6-9
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!