Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How can I plot several lines on a figure with different colours when using plotyy?

1 Ansicht (letzte 30 Tage)
Emir Cabukoglu
Emir Cabukoglu am 12 Jun. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
x=eigen_h2(:,1);
y1=profile_h2(1:15000,3);
y2=eigen_h2(:,2);
y3=eigen_h2(:,3);
y4=eigen_h2(:,4);
figure
[hAx,hLine1,hLine2] = plotyy(x,y1,[x',x',x'],[y2',y3',y4']);
I'm trying to show y2' and y3' with different colours. I can show y1 with a different color, but y2,y3 and y4 all have the same color? How can I change their colours?
Thank you!

Antworten (1)

Ingrid
Ingrid am 12 Jun. 2015
you should index the handle hLine2 (which is not a fortunate name choice as it is not the handle to the second line, but contains the handles to all the lines plotted on the secondary y-axes)
for ii = 1:4
set(hLine2(ii),'Color',colorWanted(ii,:))
end
with colorWanted a 4x3 matrix with the desired RGB values

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by