Determine where to draw graphics objects
h = newplot
h = newplot(hsave)
h = newplot(hsave) prepares and returns an axes, but does not delete any objects whose handles you have assigned to the hsave argument, which can be a vector of handles. If hsave is not empty, the figure and axes containing hsave are prepared for plotting instead of the current axes of the current figure. If hsave is empty, newplot behaves as if it were called without any inputs.
To create a simple 2-D plot, use the plot function instead.
Use newplot at the beginning of high-level graphics code to determine which figure and axes to target for graphics output. Calling newplot can change the current figure and current axes. Basically, there are three options when you are drawing graphics in existing figures and axes:
Add the new graphics without changing any properties or deleting any objects.
Delete all existing objects whose handles are not hidden before drawing the new objects.
Delete all existing objects regardless of whether or not their handles are hidden, and reset most properties to their defaults before drawing the new objects (refer to the following table for specific information).
The figure and axes NextPlot properties determine how newplot behaves. The following two tables describe this behavior with various property values.
First, newplot reads the current figure's NextPlot property and acts accordingly.
Create a new figure and use it as the current figure.
Draw to the current figure without clearing any graphics objects already present.
Remove all child objects whose HandleVisibility property is set to on and reset figure NextPlot property to add.
This clears the current figure and is equivalent to issuing the clf command.
Remove all child objects (regardless of the setting of the HandleVisibility property) and reset figure properties to their defaults, except
NextPlot is reset to add regardless of user-defined defaults.
This clears and resets the current figure and is equivalent to issuing the clf reset command.
After newplot establishes which figure to draw in, it reads the current axes' NextPlot property and acts accordingly.
Draw into the current axes, retaining all graphics objects already present.
Remove all child objects whose HandleVisibility property is set to on, but do not reset axes properties. This clears the current axes like the cla command.
Remove all child objects (regardless of the setting of the HandleVisibility property) and reset axes properties to their defaults, except Position and Units.
This clears and resets the current axes like the cla reset command.