drawnow

Updates the figures and processes pending events right away.

Category: Graphics > 2-D and 3-D Plots

Syntax

drawnow

Draws pending graphics changes and runs queued callbacks.

drawnow limitrate

Updates at most about 20 times per second, skipping the extra calls.

drawnow nocallbacks

Updates the graphics but postpones callbacks.

Description

Graphics commands are queued and normally drawn when the script pauses or finishes. Inside a long loop, drawnow forces the figure to refresh so animation frames or progress become visible. It is the usual companion of addpoints and of property changes in a loop.

Input arguments

'limitrate'
Throttle updates inside fast loops.
'nocallbacks'
Do not run pending callbacks.

Example

Animate a marker

h = plot(0, 0, 'o', 'MarkerSize', 10);
axis([0 10 -1.5 1.5])
for k = 0:0.5:10
    set(h, 'XData', k, 'YData', sin(k))
    drawnow
end
disp('done')
Output
done

See also

animatedline addpoints plot