Dear all,
I have a 2D plot, in which consist of 5 line to make a "closed cell", I wish to color the line with different color. so I try it as below
x = [0.168149323 0.547990492 0.580721962 0.502272216 0.321295719 0.168149323];
y = [0.565541486 0.530969047 0.570321397 0.878624621 1.069086578 0.565541486];
z = [0 0 0 0 0 0];
%rgb is colormap value for different line
rgb= [0.5020 0 0
0.5000 0 0
0.5000 0 0
0 0 0.5156
0 0 0.5156]
for k = 1 : length(rgb);
hold on
% Get new values.
plot(x, y,'-', 'Color', rgb(k,:) ,'LineWidth',2)
end
but all the line I get has same color instead of different color, may I know how can I make them different color based on my colormap matrix?
Thank you in advance.

 채택된 답변

KSSV
KSSV 2021년 12월 20일

2 개 추천

x = [0.168149323 0.547990492 0.580721962 0.502272216 0.321295719 0.168149323];
y = [0.565541486 0.530969047 0.570321397 0.878624621 1.069086578 0.565541486];
figure
hold on
for i = 2:length(x)
plot(x((i-1):i),y((i-1):i),'-')
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

질문:

2021년 12월 20일

댓글:

2021년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by