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:

  1. newplot checks the current figure's NextPlot property:
  2. newplot checks the current axes' NextPlot property:

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:

  1. Checks the value of the current figure's 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).
  2. Checks the value of the current axes' 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