Plot a subplot with hold on and hold off in a loop without always calling xlabel, ylabel, xlim, etc
Ältere Kommentare anzeigen
This might be really simple but I can't figure it out...I'm pretty new. I have a plot window, broken up into two subplots, lets call them A and B, which have different labels and limits. I (hold on), make several plots to B, then I (hold off), then start iterating. In the loop, I want to update both A and B with NEW plots, but I want the axis labels, and xlim and ylim to stay the same, WITHOUT having to call xlabel, xlim, etc every iteration.
Now, (hold off) destroys all axis properties. How do I save the axis properties so I don't have to keep calling xlabel, etc in the loop? I've tried newplot, setting the Nextplot property, etc to no avail. I'd like a simple solution please...not something like re-writing the plot command. Thanks!
hfig=figure();
hax = axes('Parent',hfig);
plot(hax,x,y);
hold on
plot(hax,x1,y1);
%this hold off resets the axes
hold off
while (1)
subplot('Position',[.07 .05 .92 .44]);
%I want to do this without having to call xlabel, ylabel, etc
%over and over
plot(newx, newy);
xlabel()
ylabel()
hold on
plot(newx1, newx2)
hold off
...
end
Antworten (2)
Paulo Silva
am 29 Mär. 2011
delete(findobj(gca,'Type','line')) %delete all the lines from gca
%all other axis properties should remain the same, only the lines disapear
Joe Billow
am 29 Mär. 2011
0 Stimmen
1 Kommentar
Paulo Silva
am 30 Mär. 2011
just do hold on before the loop and use my code to clear the lines from the axes
Kategorien
Mehr zu Subplots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!