How to update a plot/graph?

조회 수: 40 (최근 30일)
lucca k
lucca k 2015년 11월 9일
댓글: Walter Roberson 2021년 6월 27일
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

채택된 답변

Image Analyst
Image Analyst 2015년 11월 9일
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
Sepehr Ariaei
Sepehr Ariaei 2021년 6월 27일
Does drawnow works on semilogy too?
Walter Roberson
Walter Roberson 2021년 6월 27일
Yes, drawnow() works on all graphics updates.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Thorsten
Thorsten 2015년 11월 9일
편집: Thorsten 2015년 11월 9일
subplot(1,2,1);
plot(x, y);
drawnow

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by