Why we can't directly delete Legend entries?
7 次查看(过去 30 天)
显示 更早的评论
Hi,
As in question Why we can't directly delete Legend entries from Matlab figure?
0 个评论
回答(3 个)
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.
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
2024-1-28
@Mike D. Thank you! I was touching up an old plot for a paper: it works!
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);
0 个评论
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
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 Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!