Documentation Center

  • Trials
  • Product Updates


Update figure window and execute pending callbacks


drawnow expose
drawnow update


drawnow causes figure windows and their children to update. Any callbacks generated by user actions (for example, mouse or key presses, button clicks, and so on) are executed before drawnow returns.

Use drawnow in animation loops to update the figure during function execution and to update graphical user interfaces.

drawnow expose causes graphics and user-interface objects to refresh with all pending changes. However, it does not allow pending callbacks to execute.

drawnow update causes only user-interface objects to refresh. It does not allow pending callbacks to execute and does not refresh graphics objects.

    Note:   On Macintosh systems, drawnow update produces the same results as described for drawnow expose

Other Actions That Cause Queue Processing

Other actions and function calls that cause the MATLAB® software to flush the queue and update the figure include:

  • Returning to the MATLAB prompt

  • Executing the following functions:

    • figure

    • getframe

    • input

    • pause

    • keyboard

  • Functions that wait for user input (i.e., waitforbuttonpress, waitfor, ginput)

  • Any code that causes one of the above functions to execute. For example, suppose h is the handle of an axes. Calling axes(h) causes its parent figure to be made the current figure and brought to the front of all displayed figures, which is the equivalent of executing a drawnow.


Using drawnow in a loop causes the display to update while the loop executes:

t = 0:pi/100:2*pi;
y = exp(sin(t));
h = plot(t,y,'YDataSource','y');
for k = 1:0.01:10
   y = exp(sin(t.*k));

See Also

| |

Was this topic helpful?