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,

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.

: newplot()

: newplot(hfig)

: newplot(hax)

: hax =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. newplot
queries the "NextPlot" field of the current figure and axis to
determine what to do.

Figure NextPlot

Action

"new"

Create a new figure and make it the current figure.

"add" (default)

Add new graphic objects to the current
figure.

"replacechildren"

Delete child objects whose
HandleVisibility is set to "on". Set NextPlot property to
"add". This typically clears a figure, but leaves in place hidden
objects such as menubars. This is equivalent to clf.

"replace"

Delete all child objects of the figure and
reset all figure properties to their defaults. However, the following
four properties are not reset: Position, Units, PaperPosition, PaperUnits.
This is equivalent to clf reset.

Axis NextPlot

Action

"add"

Add new graphic objects to the current axes. This
is equivalent to hold on.

"replacechildren"

Delete child objects whose
HandleVisibility is set to "on", but leave axis properties
unmodified. This typically clears a plot, but preserves special settings
such as log scaling for axes. This is equivalent to cla.

"replace" (default)

Delete all child objects of the
axis and reset all axis properties to their defaults. However, the
following properties are not reset: Position, Units. This is equivalent
to cla reset.

If the optional input hfig or hax is given then prepare the
specified figure or axes rather than the current figure and axes.

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

Caution: Calling newplot may change the current figure and
current axis.

: hold

: holdon

: holdoff

: 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. Line color and line style are advanced for each new plot
added.

hold all (deprecated)

Equivalent to hold on.

hold off

Restore default graphics settings which clear the graph and reset axis
properties before each new plot command. (default).

hold

Toggle the current hold state.

When given the additional argument hax, the hold state is modified
for this axis rather than the current axes returned by gca.

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.

If the optional argument "reset" is specified, delete all child
objects including those with hidden handles and reset all figure
properties to their defaults. However, the following properties are not
reset: Position, Units, PaperPosition, PaperUnits.

If the first argument hfig is a figure handle, then operate on
this figure rather than the current figure returned by gcf.

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

If the optional argument "reset" is specified, delete all child
objects including those with hidden handles and reset all axis properties
to their defaults. However, the following properties are not reset:
Position, Units.

If the first argument hax is an axes handle, then operate on
this axis rather than the current axes returned by gca.

When called with no arguments, close the current figure. This is equivalent
to close (gcf). If the input h is a graphic handle, or vector
of graphics handles, then close each figure in h.

If the argument "all" is given then all figures with visible handles
(HandleVisibility = "on") are closed.

If the argument "all hidden" is given then all figures, including
hidden ones, are closed.

If the argument "force" is given then figures are closed even when
"closerequestfcn" has been altered to prevent closing the window.

Implementation Note: close operates by calling the function specified
by the "closerequestfcn" property for each figure. By default, the
function closereq is used. It is possible that the function invoked
will delay or abort removing the figure. To remove a figure without
executing any callback functions use delete. When writing a callback
function to close a window do not use close to avoid recursion.