필터 지우기
필터 지우기

How to update legend in MatLab R2017a

조회 수: 4 (최근 30일)
Jamal Ahmad
Jamal Ahmad 2017년 3월 19일
답변: Mario Buchely 2018년 3월 30일
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
Romilde Kotze
Romilde Kotze 2017년 8월 23일
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?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2017년 3월 19일
In r2017a, legends should update automatically. It is one of the graphics changes in the release
  댓글 수: 4
Romilde Kotze
Romilde Kotze 2017년 8월 23일
Unfortunately, that doesn't solve the problem. The auto update isn't working properly
Walter Roberson
Walter Roberson 2017년 8월 23일
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.

댓글을 달려면 로그인하십시오.


Mario Buchely
Mario Buchely 2018년 3월 30일
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')

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by