Colour mismatch between plot and legend

3 visualizzazioni (ultimi 30 giorni)
Priya
Priya il 24 Giu 2014
Modificato: Priya il 6 Ago 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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by