필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Anjireddy Thatiparthy
Anjireddy Thatiparthy 2012년 11월 25일
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.

답변 (2개)

Arthur
Arthur 2012년 11월 25일
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
Azzi Abdelmalek 2012년 11월 25일
%Look at this example
t=0:0.1:10;
y1=sin(t)
y2=cos(t)*10
% plot your first data
plot(t,y1,'r')
ax1=gca
pos=double(get(ax1,'position'));
%plot your second data
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)])
%change your second plot
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)])
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 25일
But I think it's easier if you replot the two data, even the first is not changing.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by