在绘图中按顺序标记点 [英] Labeling points in order in a plot

查看:62
本文介绍了在绘图中按顺序标记点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个向量,分别表示要绘制的点(x,y)的位置.

I have two vectors representing the location of points (x,y) that I'd like to plot.

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

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

这篇关于在绘图中按顺序标记点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆