我有两个向量代表我想要绘制的点 (x,y) 的位置。
我知道如何绘制它们,但我还想将它们标记为 1、2、3、4...,并在绘图上显示可见的标签。标签代表它们在向量中的顺序。
最佳答案
这是一种方法:
p = rand(10,2);
labels = cellstr( num2str([1:10]') ); %' # labels correspond to their order
plot(p(:,1), p(:,2), 'rx')
text(p(:,1), p(:,2), labels, 'VerticalAlignment','bottom', ...
'HorizontalAlignment','right')
关于matlab - 在图中按顺序标记点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4140312/