Clearing axis data from a GUIDE-generated figure

1 次查看(过去 30 天)
Hi folks,
I'm having some difficulty processing data on a figure generated in GUIDE. The first task is to plot some data from a text file, as you can see below:
When the forward (play) button is pressed, I would like the plot data on the axes titled "Hysteresis Loop" to be cleared, but I can't seem to find a way to achieve this. There is no handle property that seems to do this, and using cla does not work either.
Trying to manually plot over the current data to clear the axes doesn't work properly either:
Here we can see that, instead of clearing the graph and re-plotting the new data, it only plots a single point.
Is there a way of simply getting rid of the old plot data without having to replace it with anything else so that I can just have a blank set of axes?
Thanks!
Louis Vallance

采纳的回答

David Sanchez
David Sanchez 2013-7-3
The following code, given by one of the contributors long ago, will help you to undo the last plotting step:
function undo_plot(h, n)
% Undo_plot(h, n) undo last 'n' plotting operations from figure(h).
% n is optional and must be a positive integer since it denotes the number of
% steps to go back in the plotting process.
if nargin == 1
n = 1;
end
if n < 1
str = sprintf('It is not humanly/machinely possible to undo %s plotting operations ! ',num2str(n));
errordlg(str,'UNDO_PLOT ERROR');
return
end
figure(h);
children = get(gca, 'children');
for i = 1 : n
delete(children(i));
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by