Why we can't directly delete Legend entries?

조회 수: 35 (최근 30일)
maro
maro 2013년 5월 12일
댓글: Andrea Mariscotti 2024년 1월 28일
Hi,
As in question Why we can't directly delete Legend entries from Matlab figure?

답변 (3개)

Mike D.
Mike D. 2018년 10월 15일
What if you didn't want to delete the curves/lines from the plot, but only wanted certain things deleted from the legend?
  댓글 수: 7
Mike D.
Mike D. 2018년 10월 16일
편집: Walter Roberson 2018년 10월 16일
I'm not seeing doMarkDirty do anything, but the following works for removing curves from legend of a mapping toolbox figure:
Select curve on the mapping figure, and type this:
h = gco;
h.Annotation.LegendInformation.IconDisplayStyle = 'off';
legend off
legend
Andrea Mariscotti
Andrea Mariscotti 2024년 1월 28일
@Mike D. Thank you! I was touching up an old plot for a paper: it works!

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


Image Analyst
Image Analyst 2013년 5월 12일
편집: Image Analyst 2013년 5월 12일
I don't know. You have to do it indirectly, such as by reissuing the legend command with fewer entries, or by calling findobj(), finding the entry you wish to delete, and then calling delete(itemHandle). Calling legend() again is not too bad - you already have the strings, so it's not too much trouble just to leave one off - that's about the same work to do than if you did something like (unsupported) legend('Remove', stringToRemove);

Jacob Moreland
Jacob Moreland 2018년 3월 1일
This is an old question, but this works in MATLAB 2015a, delete the lines you want to remove from the legend, delete the legend, and then ctrl-z to bring the legend back, and the legend should come back with only the legend entries removed.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 3월 1일
With recent versions of MATLAB, delete the lines you want to remove from the legend, and then command
legend show
to have it update the legend.

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

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by