Clearing axis data from a GUIDE-generated figure

조회 수: 1 (최근 30일)
fsgeek
fsgeek 2013년 7월 3일
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
  댓글 수: 1
fsgeek
fsgeek 2013년 7월 3일
This works perfectly and solves my problem. Thank you, Mr. Sanchez.
Louis Vallance

댓글을 달려면 로그인하십시오.

추가 답변 (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