when i have two plots on same figure, how can i clear only one plot ??
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (2)
Arthur
el 25 de Nov. de 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)
0 comentarios
Azzi Abdelmalek
el 25 de Nov. de 2012
%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 comentario
Azzi Abdelmalek
el 25 de Nov. de 2012
But I think it's easier if you replot the two data, even the first is not changing.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!