Label index/variable name near data points
14 次查看(过去 30 天)
显示 更早的评论
Hello I,m looking for solution to print a index near to data point:
The example values are:
M =
2278 2 685 2
197 2 2221 2
524 2 2496 2
1061 2 3415 2
651 2 5810 2
1105 2 3817 2
276 2 4527 2
I want to have a text box near to (2278,2) 1; (197,2) 2 .....
lables = 1 %lables = (1:k)
figure('Name','Result','NumberTitle','on');
hold on
p11 = plot(M(:,2),M(:,1),'ro','Color','g');
hold on
p12 = plot(M(:,4),M(:,3),'rx','Color','r');
text(M(:,4),M(:,3),labels,'VerticalAlignment','bottom','HorizontalAlignment','right')
xlabel('tube dimension')
ylabel('Results')
tube_size_help = sprintf('%.0f',tube_size);
nameX=strcat(name ,'_tube_size_',tube_size_help);
saveas(gcf, [nameX '_results.png'])
But I get everythere the same value. Hov can I insert a changing index of row near to M(row,2),M(row,1) (or names of measures)
for loop? Or somethink better?
Thank you!
0 个评论
采纳的回答
Adam Danz
2020-6-15
figure('Name','Result','NumberTitle','on');
hold on
p11 = plot(M(:,2),M(:,1),'ro','Color','g');
hold on
p12 = plot(M(:,4),M(:,3),'rx','Color','r');
labelpoints(M(:,4),M(:,3), 1:size(M,1), 'E', 0.2)
% "E" means "east" of the coordinate
% 0.2 is a buffer space between the label and the marker
6 个评论
Adam Danz
2020-6-17
Good! I should also mention that you can click-and-drag the labels after they are plotted, too, in case you need to make final adjustments to a figure you intend to present or publish.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!