drawnow — Present pending figure updates and process graphics callbacks.
drawnow asks the selected graphics host to present pending figure updates and process callbacks. Its control forms can rate-limit presentation or defer callbacks without discarding them.
Syntax
drawnow
drawnow control
drawnow limitrate nocallbacks
ok = drawnow
ok = drawnow control
ok = drawnow limitrate nocallbacksInputs
control- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- limitrate, nocallbacks, update, or expose.
limitrate- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Limit presentation to at most 20 updates per second.
nocallbacks- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Defer pending callbacks until a later full flush.
Returns
ok- Type
LogicalArray- Description
- RunMat-only status for a completed host flush.
Errors
RunMat:drawnow:InvalidControl- When
- A control token is unknown, duplicated, conflicting, or in an unsupported order.
- Message
drawnow: invalid control
RunMat:drawnow:TooManyOutputs- When
- More than one output is requested.
- Message
drawnow: too many output arguments
RunMat:drawnow:PresentationFailed- When
- The selected host fails to present a figure or process callbacks.
- Message
drawnow: graphics presentation failed
- When
- Operand materialization or runtime control flow fails with its original cause.
- Message
drawnow: internal error
Forms
drawnow requests an immediate presentation and processes queued graphics callbacks. It does not create a figure when none exists; callback processing is a separate host obligation even in that case.
drawnow limitrate skips presentation when the renderer is busy or fewer than 50 ms have elapsed since its last presentation, but still processes callbacks. drawnow nocallbacks presents without processing callbacks; those callbacks remain queued for a later full flush. The two controls can be combined as drawnow limitrate nocallbacks.
Legacy drawnow update skips presentation only while busy and defers callbacks; it is not a 50 ms limit-rate request. Legacy drawnow expose presents immediately and defers callbacks. Both forms remain supported but are not recommended for new code.
Host and output behavior
The active native, browser, or Desktop presentation service owns the window/canvas receipt and callback queue. A numeric figure handle alone does not grant host or session authority. A host without a graphics presentation service fails with a typed capability error rather than reporting a successful no-op.
MATLAB-compatible calls are statements with no output. Requesting a logical completion status is a RunMat-only extension. A rate-limited call may complete without presenting a new frame; its status reports host completion, not proof of new pixels.
The call can suspend. Cancellation before dispatch has no host effect; once a host request may have committed, a lost acknowledgement is indeterminate rather than falsely reported as unpublished.
Examples
Present a changed plot
x = 0:0.1:1;
plot(x,x.^2);
drawnow;Limit presentation while updating an animated line
h = animatedline;
for k = 1:10
addpoints(h,k,sin(k));
drawnow limitrate;
end
drawnow;Using drawnow with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how drawnow changes the result.
Run a small drawnow example, explain the result, then change one input and compare the output.
FAQ
Does drawnow create a figure?⌄
No. It can still process queued callbacks when there is no figure to present.
Does limitrate discard callbacks?⌄
No. It can defer a frame, but callbacks are processed unless nocallbacks is also requested.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Source you can read
Every RunMat function's source is public. Read exactly how drawnow is executed, line by line, in Rust.
- View the source for drawnow in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.