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