plotting 13 lines with different colors !!

조회 수: 54 (최근 30일)
Ahmed
Ahmed 2013년 2월 12일
댓글: Sterre de Lignie 2022년 6월 16일
i am plotting about 15 different lines in the same graph and i need more color codes than the existing 8 which are (r g b k c m y w)can any one help ??

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 2월 12일
편집: Sean de Wolski 2013년 2월 12일
Use the RGB components explicitly:
h = zeros(20,1);
figure; hold on
for ii = 1:20;
h(ii) = plot(1:10,cumsum(rand(1,10)),'Color',rand(1,3));
end
legend(h);
  댓글 수: 3
Jan
Jan 2013년 2월 12일
Random colors are not a guarantee, that there are different colors.
Sean de Wolski
Sean de Wolski 2013년 2월 12일
the odds are in my favor ;)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Jan
Jan 2013년 2월 12일
편집: Jan 2013년 2월 12일
You can use RGB colors, which are defined by a [1 x 3] vector. There are several colormaps available in Matlab already, e.g.:
cmap = jet(15);
for k = 1:15
line(1:10, rand(1:10)+k, 'Color', cmap(k, :));
end
  댓글 수: 2
Bruno Pedroni
Bruno Pedroni 2018년 9월 5일
cmap = jet(15);
for k = 1:15
line(1:10, rand(1,10)+k, 'Color', cmap(k, :));
end
Sterre de Lignie
Sterre de Lignie 2022년 6월 16일
For me this worked very nicely!

댓글을 달려면 로그인하십시오.


Korosh Agha Mohammad Ghasemi
Korosh Agha Mohammad Ghasemi 2020년 12월 7일
.
%https://zil.ink/korosh -------- Ways to contact me ----------
% Korosh Agha Mohammad Ghasemi !
% Chemical Engineering at Shiraz University
x=linspace(0,2,100);
figure;
for a=[0.1 0.5 1 2 4]
y=x.^a; %The function is hypothetical
if a == 0.1 %Any color can be substituted
y=x.^a;
plot(x,y,'k') %Now choose the color
hold on
elseif a == 0.5
y=x.^a;
plot(x,y,'b') %Now choose the color
hold on
elseif a==1
y=x.^a;
plot(x,y,'g') %Now choose the color
hold on
elseif a==2
y=x.^a;
plot(x,y,'r') %Now choose the color
hold on
elseif a==4
y=x.^a;
plot(x,y,'y') %Now choose the color
hold on
grid on
end
end

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by