How to create moving text

16 visualizzazioni (ultimi 30 giorni)
Rajawarman Thiruselvam
Rajawarman Thiruselvam il 6 Lug 2021
Modificato: Jonas il 7 Lug 2021
Is it possible to create a moving text along with a line??

Risposta accettata

Jonas
Jonas il 6 Lug 2021
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 Commenti
Rajawarman Thiruselvam
Rajawarman Thiruselvam il 7 Lug 2021
and this ??
tx.Position=[x(k),1.1*y(k)]
Jonas
Jonas il 7 Lug 2021
Modificato: Jonas il 7 Lug 2021
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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by