How to create moving text

15 次查看(过去 30 天)
Is it possible to create a moving text along with a line??

采纳的回答

Jonas
Jonas 2021-7-6
you can move the text every now and then by changing the coordinates. e.g.
data=randi(42,100,1);
m=mean(data);
plot(data);
yline(m);
tx=text(1,1.1*m,'some text','Color','r');
for xCor=2:80
tx.Position=tx.Position+[1 0 0];
pause(0.1)
end
  5 个评论
Jonas
Jonas 2021-7-7
编辑:Jonas 2021-7-7
tx=text(x(1),1.1*y(1),'lead');
creates the text label 'lead' near x(1) and y(1). i used 1.1*y(1) to be sure that the label is not exactly on the point of the curve i want to label but a bit above
similarly i use a slightly bigger y when i move the label according to the further points of the curve

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by