poster
2019-12-10, 20:48
我有两个向量代表要绘制的点(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') https://i.stack.imgur.com/NaKG9.png
更多&回答... (https://stackoverflow.com/questions/4140312)
我知道如何绘制它们,但我也想用在图中可见的标签来标记它们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') https://i.stack.imgur.com/NaKG9.png
更多&回答... (https://stackoverflow.com/questions/4140312)