Colour mismatch between plot and legend

1 次查看(过去 30 天)
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