Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Legend needs to be turned off and on again to be shown correctly

1 回表示 (過去 30 日間)
Lucas-Raphael Müller
Lucas-Raphael Müller 2016 年 6 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, I've got a problem using the legend for a matlab plot: I plot multiple plots in one figure and need to dispay the legend for some plots and for some not. Here is a part of code I use:
figure
for i=1:100
p(i) = plot(x,y, 'DisplayName', name{i});
legend('-DynamicLegend');
hold all;
if i~= 1 && i~= 100
set(get(get(p(i),'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
end
end
p(i + 1) = plot(a,b, 'DisplayName', 'test1');
p(i + 2) = plot(c,d, 'DisplayName', 'test2');
hold off;
The problem is that the figure which is shown only shows the name name{1} and name{100} and without the box. As soon as I disable the legend in the figure (after it has been produced by matlab) and enable it again the legend is shown with a box and with name{1}, name{100} and test1 and test2 which is correct. Am I missing something or is it a bug? Is there maybe a workaround to disable and enable automatically?
Cheers

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by