Colour mismatch between plot and legend

조회 수: 6 (최근 30일)
Priya
Priya 2014년 6월 24일
편집: Priya 2014년 8월 6일
I don't know why the legend and plots don't match. I get the legend colours as defined below but the plot colours are all blue.
myh = line([xCenter, xCenter], [yCenter - yRadius(k2), yCenter + yRadius(k2)], ...
'LineWidth', 1, 'Color', [1,0,0]);
set(get(get(myh,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
myh = line([xCenter - xRadius(k2), xCenter + xRadius(k2)], [yCenter, yCenter], ...
'LineWidth', 1, 'Color', [1,0,0]);
set(get(get(myh,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
end

채택된 답변

dpb
dpb 2014년 6월 24일
See if this thread helps--
Particularly, note the cyclist's answer...
  댓글 수: 5
dpb
dpb 2014년 6월 24일
Must not have been the identical code; as the error says when that code ran you incremented the index into the colors array before addressing it so ran off the end.
Why not just write
figure
for k1 = 1:5
plot(x, y, colors(k1), 'LineWidth', 1);
if k1==1, hold on, end
end
? What's the point of all the extra obfuscation?
Priya
Priya 2014년 6월 25일
Well, thanks for your reply, I'll try it out.

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

추가 답변 (0개)

카테고리

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