In MATLAB, I plot many different vectors to a figure. Now, what I would like to do is simply undo the last vector that I plotted to that figure, without clearing everything else. How can this be accomplished? Can it be accomplished?
Thanks
Edit:
figure(1); clf(1);
N = 100;
x = randn(1,N);
y = randn(1,N);
z = sin(1:N);
plot(x); hold on;
plot(y,'r');
plot(z,'k');
Now here, I would like to remove the plot z, which was the last plot I made.
To clear the contents of a figure, you can alternatively use Clear Figure from the figure window's Edit menu. Using Clear Figure deletes all children of the figure that have visible handles.
clf() clears the entire current figure with all its axes, but leaves the window opened, such that it may be reused for other plots. plt. close() closes a window, which will be the current window, if not specified otherwise.
Clear Axes and Reset All Axes PropertiesCreate a line plot and set the axis limits. Clear the line plot from the axes and reset all the axes properties to their default values. cla reset resets all properties of the current axes, except for the Position and Units properties.
If you know before plotting that you want to remove it again later, you can save the handle returned by plot
and delete
it afterwards.
figure;
h1 = plot([0 1 2], [3 4 5]);
delete(h1);
Try
items = get(gca, 'Children');
delete(items(end));
(or maybe delete(items(1))
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With