plotting 3 lines in same axes (same figure) with different colors
1 view (last 30 days)
Show older comments
sermet
on 18 Jul 2014
Commented: Seetha Rama Raju Sanapala
on 18 Jul 2014
ids=[1;2;3;4;5;6;7;8;9;10];
dx=[0.1;0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9;0.10];
dy=[0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09;0.10];
dz=[1;2;3;4;5;6;7;8;9;10];
figure;
plot(ids,dx)
%I need to plot dx,dy,dz w.r.t ids in the same figure with different colors like blue,red,black.
1 Comment
Seetha Rama Raju Sanapala
on 18 Jul 2014
The command 'figure' is not necessary here. Also you can simplify your coding like dz=[1:10] or dz=[1:10]' if you want a column vector only - though for your purpose row or column vector does not matter.
Accepted Answer
Joseph Cheng
on 18 Jul 2014
if you check the documentation for plot() it gives good examples of what you can do
ids=[1;2;3;4;5;6;7;8;9;10];
dx=[0.1;0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9;0.10];
dy=[0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09;0.10];
dz=[1;2;3;4;5;6;7;8;9;10];
figure;
plot(ids,dx,'b',ids,dy,'r',ids,dz,'k')
1 Comment
Joseph Cheng
on 18 Jul 2014
'b'=blue 'r'=red 'k'=black 'y'=yello 'c'=cyan
etc. plot documentation will also give how to create line dashes, markers, etc.
More Answers (1)
Azzi Abdelmalek
on 18 Jul 2014
ids=[1;2;3;4;5;6;7;8;9;10];
dx=[0.1;0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9;0.10];
dy=[0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09;0.10];
dz=[1;2;3;4;5;6;7;8;9;10];
plot(ids,[dx dy dz])
0 Comments
See Also
Categories
Find more on Annotations 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!