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

4 ビュー (過去 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 Center および File ExchangeAnnotations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by