开发者

Labeling points in order in a plot

I have开发者_开发百科 two vectors representing the location of points (x,y) that I'd like to plot.

I know how to plot them, but I'd also like to label them 1, 2, 3, 4... with labels visible on the plot. The labels represent their order in the vector.


Here's one way to do this:

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

Labeling points in order in a plot

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜