Why we can't directly delete Legend entries?

7 ビュー (過去 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 Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by