フィルターのクリア

Legend does not refresh after hold command

4 ビュー (過去 30 日間)
Aurelien Queffurust
Aurelien Queffurust 2012 年 3 月 2 日
Let'say I plot 2 lines and I want to display a legend
plot(1:10,'b','displayname','1st graph')
hold on
plot(3:5,'r','displayname','2ng graph')
legend('show')
It works as expected, I have a legend and 2 annotations.
Not let's say I also want to display the legend before the hold command (for any reason) :
plot(1:10,'b','displayname','1st graph')
legend('show')
hold on
plot(3:5,'r','displayname','2ng graph')
legend('show')
This time only the first annotation is displayed . I expected that recalling legend will refresh the legend information.
  1. Is it the expected behavior?
  2. What are the best practices to call legend ?
  3. Do we have to call legend ONCE and only after having plotted everything?
Thanks for your tips,
Aurélien

採用された回答

Aurelien Queffurust
Aurelien Queffurust 2012 年 9 月 20 日
I have just noticed that there was no answer . Since this question I found 3 workarounds :
This is one :
plot(1:10,b',displayname,1st graph)
legend(-DynamicLegend);
legend(show)
hold on
plot(3:5,r',displayname,2ng graph)
legend(show)
Another solution from Yair : here

その他の回答 (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