我有两个 vector 代表要绘制的点(x,y)的位置。

我知道如何绘制它们,但我也想用在图中可见的标签来标记它们1、2、3、4...。标签表示它们在 vector 中的顺序。

最佳答案

这是执行此操作的一种方法:

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')

10-05 21:00
查看更多