Clearing axis data from a GUIDE-generated figure

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

David Sanchez
David Sanchez il 3 Lug 2013
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
  1 Commento
fsgeek
fsgeek il 3 Lug 2013
This works perfectly and solves my problem. Thank you, Mr. Sanchez.
Louis Vallance

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by