Tweak legend entries without creating a new legend
11 ビュー (過去 30 日間)
古いコメントを表示
I have created a plot with a legend and now I would like to edit legend entries without recreating the whole legend. For example, for five legend entries I would like to reorder them like
newOrder = [2 3 5 4 1];
I can reorder the entries by first getting current legend handles and strings like this:
[~,~,plot_h,text_strings] = legend;
And then I can reorder the entries like this:
legend(plot_h(newOrder),text_strings{newOrder})
However, this doesn't only reorder the legend; it seems to delete the legend I'd already created, with its perfect placement and color scheme, etc, and creates a new legend with entries in the correct new order. How can I edit these entries without screwing up the placement, colors, boxoff, etc that I've already set?
0 件のコメント
採用された回答
その他の回答 (2 件)
Rodrigo Bernal
2021 年 7 月 13 日
Edit a specific legend entry of an existing legend:
figu=gca;
figu.Legend.String(6)={'Edit the 6th legend'};
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!