Documentation

newplot

Determine where to draw graphics objects

Syntax

newplot
h = newplot
h = newplot(sv)

Description

newplotprepares a figure and axes for subsequent graphics commands.

h = newplotprepares a figure and axes for subsequent graphics commands and returns the current axes.

h = newplot(sv)does not delete any objects specified by thesvargument, which can be a vector of graphics objects. The figure and axes containing the objects insvare prepared for plotting instead of the current axes of the current figure. Ifsvis empty,newplotbehaves as if it were called without any inputs.

Tips

To create a simple 2-D plot, use theplotfunction instead.

Usenewplotat the beginning of high-level graphics code to determine which figure and axes to target for graphics output. Callingnewplotcan 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.

  • 删除所有现有的对象处理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 axesNextPlotproperties determine hownewplotbehaves. The following two tables describe this behavior with various property values.

First,newplotreads the current figure'sNextPlotproperty and acts accordingly.

NextPlot

What Happens

new

Create a new figure and use it as the current figure.

add

Draw to the current figure without clearing any graphics objects already present.

replacechildren

Remove all child objects whoseHandleVisibilityproperty is set toonand reset figureNextPlotproperty toadd.

This clears the current figure and is equivalent to issuing theclfcommand.

replace

Remove all child objects (regardless of the setting of theHandleVisibilityproperty) and reset figure properties to their defaults, except

NextPlotis reset toaddregardless of user-defined defaults.

This clears and resets the current figure and is equivalent to issuing theclfresetcommand.

Afternewplotestablishes which figure to draw in, it reads the current axes'NextPlotproperty and acts accordingly.

NextPlot

Description

add

Add new plots to the existing axes. Do not delete existing plots or reset axes properties before displaying the new plot.

replacechildren

Delete existing plots before displaying the new plot. Reset theColorOrderIndexandLineStyleOrderIndexaxes properties to 1, but do not reset other axes properties. The next plot added to the axes uses the first color and line style based on theColorOrderandLineStyleOrderproperties of the axes. This value is similar to usingclabefore every new plot.

replace

Delete existing plots and reset all axes properties, exceptPositionandUnits, to their default values before displaying the new plot.

replaceall

Delete existing plots and reset all axes properties, exceptPositionandUnits, to their default values before displaying the new plot. This value is similar to usingcla resetbefore every new plot.

For axes with only oney-axes, thereplaceandreplaceallvalues are equivalent. For axes with twoy-axes, thereplacevalue affects only the active side while thereplaceallvalue affects both sides.

Introduced before R2006a

Was this topic helpful?