How to update a plot/graph?

40 vues (au cours des 30 derniers jours)
lucca k
lucca k le 9 Nov 2015
Commenté : Walter Roberson le 27 Juin 2021
Hello everybody,
I got a plot like this one:
h = subplot(1,2,1);
plot(0, 0);
axis([-30 40 -20 100 ]);
grid on
Now I am getting a new array of x,y - points every second. How can I update the subplot h with these arrays? It is an n by 2 single array.
Thank you in advance!
Lucca

Réponse acceptée

Image Analyst
Image Analyst le 9 Nov 2015
In your loop where you get new x,y arrays, make sure you have this line after the plot:
plot(.................
drawnow;
drawnow will force the plot to update immediately. Otherwise it probably won't get around to it until the loop is entirely finished so that all you will see is the very last set of data plotted.
  2 commentaires
Sepehr Ariaei
Sepehr Ariaei le 27 Juin 2021
Does drawnow works on semilogy too?
Walter Roberson
Walter Roberson le 27 Juin 2021
Yes, drawnow() works on all graphics updates.

Connectez-vous pour commenter.

Plus de réponses (1)

Thorsten
Thorsten le 9 Nov 2015
Modifié(e) : Thorsten le 9 Nov 2015
subplot(1,2,1);
plot(x, y);
drawnow

Catégories

En savoir plus sur Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by