Graphics |
Targeting Graphics Output with newplot
MATLAB provides the newplot
function to simplify the process of writing graphics M-files that conform to the settings of the NextPlot
properties.
newplot
checks the values of the NextPlot
properties and takes the appropriate action based on these values. You should place newplot
at the beginning of any M-file that calls object creation functions.
When your M-file calls newplot
, the following possible actions occur:
newplot
checks the current figure's NextPlot
property:
newplot
creates one and makes it the current figure.
NextPlot
is add
, newplot
makes the figure the current figure.
NextPlot
is replacechildren
, newplot
deletes the figure's children (axes objects and their descendents) and makes this figure the current figure.
NextPlot
is replace
, newplot
deletes the figure's children, resets the figure's properties to the defaults, and makes this figure the current figure.
newplot
checks the current axes' NextPlot
property:
newplot
creates one and makes it the current axes.
NextPlot
is add
, newplot
makes the axes the current axes.
NextPlot
is replacechildren
, newplot
deletes the axes' children and makes this axes the current axes.
NextPlot
is replace
, newplot
deletes the axes' children, resets the axes' properties to the defaults, and makes this axes the current axes.
MATLAB Default Behavior
Consider the default situation where the figure NextPlot
property is add
and the axes NextPlot
property is replace
. When you call newplot
, it:
NextPlot
property (which is add
) and determines MATLAB can draw into the current figure with no further action (if there is no current figure, newplot
creates one, but does not recheck its NextPlot
property).
NextPlot
property (which is replace
), deletes all graphics objects from the axes, reset all axes properties (except Position
and Units
) to their defaults, and returns the handle of the current axes.
Preparing Figures and Axes for Graphics | Example -- Using newplot |