How to update legend in MatLab R2017a

5 visualizaciones (últimos 30 días)
Jamal Ahmad
Jamal Ahmad el 19 de Mzo. de 2017
Respondida: Mario Buchely el 30 de Mzo. de 2018
I found that in the new version of MatLab, R2017a, they removed the option of updating the legend (Right-Click on legend ----> select the option Refresh). So, how one can update the legend in MatLab R2017a?
  1 comentario
Romilde Kotze
Romilde Kotze el 23 de Ag. de 2017
I have the same problem when I hide some curves. How did you manage to get the legend to refresh because it's definitely not updating automatically?

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 19 de Mzo. de 2017
In r2017a, legends should update automatically. It is one of the graphics changes in the release
  4 comentarios
Romilde Kotze
Romilde Kotze el 23 de Ag. de 2017
Unfortunately, that doesn't solve the problem. The auto update isn't working properly
Walter Roberson
Walter Roberson el 23 de Ag. de 2017
If you used the old style legend() call with multiple outputs, then legend objects are built differently and will not automatically update.
For the new-style legend() call, the legend AutoUpdate property controls automatic updating. The default is now true, but that might be overridden by a figure or root DefaultLegendAutoUpdate property.
To hide particular items, you can set their HandleVisibility off, or set their annotation IconDisplayStyle off.
According to Mathworks at https://www.mathworks.com/matlabcentral/answers/353013-in-2017a-how-do-i-prevent-a-legend-item-from-being-greyed-out-when-the-plot-line-is-set-with-visi#answer_278712 the behavior of graying legend entries for items whose visibility is off cannot be generally overridden.

Iniciar sesión para comentar.


Mario Buchely
Mario Buchely el 30 de Mzo. de 2018
Hi, I had same problem with Matlab 2017a. It seems new version uses new features that does not allow to do the 'refresh' in legend using the figure GUI. After trying different things, I just did a simple procedure: delete the non-useful plots. If you need to keep the plots, and if you don't want to mess with code, I recommend to do: 1. Deactivate the AutoUpDate property using the following command: >>menuset(groot,'defaultLegendAutoUpdate','off') 2. Open your figure in the GUI and edit all plots as you finally want to show (names, types, colors, etc.) 3. Save as figure at this point if you need to reset something 4. Select plots you don't want to show in legend 5. Delete those plots 6. Insert legend 7. Undo: Delete (Ctl+z) 8. Edit legend title and move it to the desired position 9. Save as or copy your new figure with the right legend.
Now, you should be able to show your figure using just the desire name for plots in legend. If you just miss some step, just close the figure and open the save version in the step 3. Finally, if you want to activate the AutoUpDate property of legend again, just type: >>menuset(groot,'defaultLegendAutoUpdate','on')

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by