Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Legend needs to be turned off and on again to be shown correctly
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!