MATLAB: Is there any way to selectively remove lines from a plot

axeslinesplot

Hi, I have an axes, I plot 100 lines on it then load some more data and plot another 100 lines. Is there a way of removing only the last 100 lines from the plot? Thanks in advance 🙂

Best Answer

Hi,
the easiest way is to store the handles you plot, e.g.
hPlot = zeros(100, 1);
for i=1:100
hPlot(i) = plot(someDataX, someDataY);
end
When you are unhappy with the (additional) data you plotted:
delete(hPlot);
removes them again and you can try again ...
Titus
Related Question