Can we change legend value without re-run the whole code?

1 回表示 (過去 30 日間)
SANDEEP SINGH RANA
SANDEEP SINGH RANA 2021 年 8 月 19 日
回答済み: Walter Roberson 2021 年 8 月 19 日
Hi,
Can I change the legend value without re-run the whole code as running whole code will take around 12 hours?
By mistake in the legend, I have written " user-1 , user-1" instead of " user-1, user-2".
How can I modified the plot? I did find any field to modify this.
Please help.

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 19 日
L = findobj(gcf, 'type', 'legend');
L.String{4} = 'user-2'; %to change the 4th legend
if you have multiple legends in the figure, you will have to select the correct entry in L.
I used gcf instead of gca because you might well not happen to have the correct axes as the "current" one.
If you are using App Designer then the gcf will probably not work, and you might need groot instead of gcf and you might possibly need findall instead of findobj

その他の回答 (0 件)

カテゴリ

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