cla deletes all graphics objects that have
visible handles from the current axes. The handle is visible if the
of the object is set to
'on'. The next plot added
to the axes uses the first color and line style based on the
of the axes. If axes do not exist, then this command creates one.
Plot two sine waves. Then, clear the line plots from the axes.
x = linspace(0,2*pi); y1 = sin(x); plot(x,y1) hold on y2 = sin(2*x); plot(x,y2)
cla clears the line plots and resets the
LineStyleIndex properties of the axes to 1. Subsequent plots start from the beginning of the color order and line style order. For example, plot another sine wave.
y3 = sin(3*x); plot(x,y3) hold off
Create a figure with two subplots and assign the
Axes objects to the variables
ax2. Add plots to both axes.
ax1 = subplot(2,1,1); surf(ax1,peaks) ax2 = subplot(2,1,2); contour(ax2,peaks)
Clear the surface plot from the upper subplot by specifying
ax1 as an input argument to
Now, reset all axes properties for the upper subplot, including the camera properties that control the view, by using the optional input argument
Create a line plot and set the axis limits.
x = linspace(0,2*pi); y = sin(x); plot(x,y) axis([0 5 -2 2])
Clear the line plot from the axes and reset all the axes properties to their default values.
cla reset resets all properties of the current axes, except for the
ax— Target axes
Target axes, specified as an
PolarAxes object. Use
clear specific axes, instead of the current axes.
cla command resets the
of the current axes to
cla only deletes objects with a
'on'. Therefore, if the
an object is set to
'callback' and you are in a
cla does not delete it.