Colour mismatch between plot and legend

10 views (last 30 days)
Priya
Priya on 24 Jun 2014
Edited: Priya on 6 Aug 2014
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

Accepted Answer

dpb
dpb on 24 Jun 2014
See if this thread helps--
Particularly, note the cyclist's answer...
  5 Comments
dpb
dpb on 24 Jun 2014
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 on 25 Jun 2014
Well, thanks for your reply, I'll try it out.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!