Filter löschen
Filter löschen

Colour mismatch between plot and legend

1 Ansicht (letzte 30 Tage)
Priya
Priya am 24 Jun. 2014
Bearbeitet: Priya am 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by