Can I delete one specific line from an axes

조회 수: 25 (최근 30일)
Eugene Davis
Eugene Davis 2018년 7월 30일
댓글: Woody 2018년 7월 31일
My axes has 2 lines in it. I'm using a spinner to move a vertical reference marker. Below is a snippet from the spinner callback. In a different axes object I want to keep the plot of the data and move the reference line. What I'm doing now is finding any lines in the axes and deleting all of them. Then I replot both of them, using an updated value for the x position. Seems pretty inelegant. I tried creating a handle for the specific reference to use delete() just on that one but I can't make that work.
axes(handles.LProfile);
h = findobj(gca, 'Type', 'line');
if ishandle(h)
delete(h)
end
plot(SW.LProfile,'b-')
line(handles.LProfile,[newTxprofile, newTxprofile],handles.LProfile.YLim)
  댓글 수: 1
Woody
Woody 2018년 7월 31일
You can add a tag on your reference line, and delete based on the tag
line(x,y,'tag','reference');
delete(findobj('tag','reference'));

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by