Next: , Previous: Use of axis, line, and patch Functions, Up: High-Level Plotting


15.2.7 Manipulation of Plot Windows

By default, Octave refreshes the plot window when a prompt is printed, or when waiting for input. The drawnow function is used to cause a plot window to be updated.

— Built-in Function: drawnow ()
— Built-in Function: drawnow ("expose")
— Built-in Function: drawnow (term, file, mono, debug_file)

Update figure windows and their children. The event queue is flushed and any callbacks generated are executed. With the optional argument "expose", only graphic objects are updated and no other events or callbacks are processed. The third calling form of drawnow is for debugging and is undocumented.

Only figures that are modified will be updated. The refresh function can also be used to force an update of the current figure, even if it is not modified.

— Function File: refresh ()
— Function File: refresh (h)

Refresh a figure, forcing it to be redrawn. When called without an argument the current figure is redrawn. Otherwise, the figure pointed to by h is redrawn.

See also: drawnow.

Normally, high-level plot functions like plot or mesh call newplot to initialize the state of the current axes so that the next plot is drawn in a blank window with default property settings. To have two plots superimposed over one another, use the hold function. For example,

     hold on;
     x = -10:0.1:10;
     plot (x, sin (x));
     plot (x, cos (x));
     hold off;

displays sine and cosine waves on the same axes. If the hold state is off, consecutive plotting commands like this will only display the last plot.

— Function File: newplot ()
— Function File: h = newplot ()

Prepare graphics engine to produce a new plot. This function is called at the beginning of all high-level plotting functions. It is not normally required in user programs.

The optional return value h is a graphics handle to the created axes (not figure).

— Command: hold
— Command: hold state
— Function File: hold (hax, ...)

Toggle or set the "hold" state of the plotting engine which determines whether new graphic objects are added to the plot or replace the existing objects.

hold on
Retain plot data and settings so that subsequent plot commands are displayed on a single graph.
hold all
Retain plot line color, line style, data and settings so that subsequent plot commands are displayed on a single graph with the next line color and style.
hold off
Clear plot and restore default graphics settings before each new plot command. (default).
hold
Toggle the current hold state.

When given the additional argument hax, the hold state is modified only for the given axis handle.

To query the current hold state use the ishold function.

See also: ishold, cla, newplot, clf.

— Command: ishold
— Function File: ishold (h)

Return true if the next plot will be added to the current plot, or false if the plot device will be cleared before drawing the next plot.

Optionally, operate on the graphics handle h rather than the current plot.

See also: hold.

To clear the current figure, call the clf function. To clear the current axis, call the cla function. To bring the current figure to the top of the window stack, call the shg function. To delete a graphics object, call delete on its index. To close the figure window, call the close function.

— Function File: clf ()
— Function File: clf ("reset")
— Function File: clf (hfig)
— Function File: clf (hfig, "reset")
— Function File: h = clf (...)

Clear the current figure window. clf operates by deleting child graphics objects with visible handles (handlevisibility = on). If hfig is specified operate on it instead of the current figure. If the optional argument "reset" is specified, all objects including those with hidden handles are deleted.

The optional return value h is the graphics handle of the figure window that was cleared.

See also: cla, close, delete.

— Function File: cla ()
— Function File: cla ("reset")
— Function File: cla (hax)
— Function File: cla (hax, "reset")

Delete the children of the current axes with visible handles. If hax is specified and is an axes object handle, operate on it instead of the current axes. If the optional argument "reset" is specified, also delete the children with hidden handles.

See also: clf.

— Command: shg

Show the graph window. Currently, this is the same as executing drawnow.

See also: drawnow, figure.

— Function File: delete (file)
— Function File: delete (handle)

Delete the named file or graphics handle.

Deleting graphics objects is the proper way to remove features from a plot without clearing the entire figure.

See also: clf, cla, unlink.

— Command: close
— Command: close (n)
— Command: close all
— Command: close all hidden

Close figure window(s) by calling the function specified by the "closerequestfcn" property for each figure. By default, the function closereq is used.

See also: closereq.

— Function File: closereq ()

Close the current figure and delete all graphics objects associated with it.

See also: close, delete.