## when i have two plots on same figure, how can i clear only one plot ??

### Anjireddy Thatiparthy (view profile)

on 25 Nov 2012
I have two plots.
Out of which one is permanent data, which is not varying with time.
Second one is varying frequently with time.
I want to clear only the second one every time. What is the procedure to do it.

### Arthur (view profile)

on 25 Nov 2012

Are there 2 axes, or 2 lines in one axes? If you have two axes: uou need the handles of the second axes to clear it with cla.
cla(axeshandle)
With 2 lines on the same axes, you can use the handle of the line that you plot:
linehandle = plot(yourdata);
%and to delete it:
delete(linehandle)

### Azzi Abdelmalek (view profile)

on 25 Nov 2012

%Look at this example
t=0:0.1:10;
y1=sin(t)
y2=cos(t)*10
plot(t,y1,'r')
ax1=gca
pos=double(get(ax1,'position'));
ax2=axes('position',pos,'color','none')
plot(t,y2,'g','parent',ax2)
set(ax2,'visible','off')
ax3=axes('position',pos,'color','none','xtick',[],'Yaxislocation','right','ylim',[min(y2) max(y2)])
y2=t.^2;
cla(ax2);
set(ax3,'visible','off')
plot(t,y2,'g','parent',ax2)
set(ax2,'visible','off')
ax3=axes('position',pos,'color','none','xtick',[],'Yaxislocation','right','ylim',[min(y2) max(y2)])

Azzi Abdelmalek

### Azzi Abdelmalek (view profile)

on 25 Nov 2012
But I think it's easier if you replot the two data, even the first is not changing.