how to change color for a 2D plot
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!