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

2 vues (au cours des 30 derniers jours)
SANDEEP SINGH RANA
SANDEEP SINGH RANA le 19 Août 2021
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Août 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

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by