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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 19 Ago 2021
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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by