Graphics |
Preparing Figures and Axes for Graphics
By default, commands that generate graphics output display the graphics objects in the current figure without clearing or resetting figure properties. However, if the graphics objects are axes children, MATLAB clears the axes and resets most axes properties to their default values before displaying the objects.
You can change this behavior by setting the figure and axes NextPlot
properties.
Using NextPlot to Control Output Target
MATLAB high-level graphics functions check the value of the NextPlot
properties to determine whether to add, clear, or clear and reset the figure and axes before drawing. Low-level object creation functions do not check the NextPlot
properties. They simply add the new graphics objects to the current figure and axes.
Low-level functions are designed primarily for use in M-files where you can implement whatever drawing behavior you want. However, when you develop a MATLAB-based application, controlling MATLAB drawing behavior is essential to creating a program that behaves predictably.
This table summarizes the possible values for the NextPlot
property.
Note that a reset
returns all properties, except Position
and Units
, to their default values.
The hold
command provides convenient access to the NextPlot
properties. The statement
sets both figure and axes NextPlot
to add
.
sets the axes NextPlot
property to replace
.
Specifying the Target for Graphics Output | Targeting Graphics Output with newplot |