plotting 3 lines in same axes (same figure) with different colors

20 views (last 30 days)
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
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.

Sign in to comment.

Accepted Answer

Joseph Cheng
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
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.

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
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])

Tags

Community Treasure Hunt

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

Start Hunting!