Delete line in GUI
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello community,
I have got a GUI with axes. I've made a function which plot a line when I click mouse button. I need to delete previous line when I plot new one, but I want to leave alone other lines. How can I do that?
Andrew
댓글 수: 0
답변 (2개)
Jan
2013년 1월 10일
You can store the handles of objects you want to delete later:
AxesH = axes('NextPlot', 'add');
LineH = plot(1:10, rand(1, 10));
set(AxesH, 'UserData', LineH);
...
pause(2);
OldLineH = get(AxesH, 'UserData');
delete(OldLineH);
LineH = plot(1:10, rand(1, 10));
Setting 'NextPlot' to 'add' is equivalent to "hold on". Setting it to 'replace' let the plot() command remove all previously plotted objects automatically.
댓글 수: 0
Azzi Abdelmalek
2013년 1월 10일
A new plot will automatically erase the previous plot, unless there is something else then a line in your previous plot.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!