Graphics Previous page   Next Page

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 values 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.

NextPlot
Figure
Axes
new
Create a new figure and use it as the current figure.
Not an option for axes.
add
Add new graphics objects without clearing or resetting the current figure. (Default setting)
Add new graphics objects without clearing or resetting the current axes.
replacechildren
Remove all child objects, but do not reset figure properties. Equivalent to clf.
Remove all child objects, but do not reset axes properties. Equivalent to cla.
replace
Remove all child objects and reset figure properties to their defaults. Equivalent to clf reset.
Remove all child objects and reset axes properties to their defaults. Equivalent to cla reset. (Default setting)

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 properties to add.

The statement

sets the axes NextPlot property to replace.


Previous page  Specifying the Target for Graphics Output Targeting Graphics Output with newplot Next page

© 1994-2005 The MathWorks, Inc.