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

15 visualizzazioni (ultimi 30 giorni)
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 Commento
Seetha Rama Raju Sanapala
Seetha Rama Raju Sanapala il 18 Lug 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.

Accedi per commentare.

Risposta accettata

Joseph Cheng
Joseph Cheng il 18 Lug 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 Commento
Joseph Cheng
Joseph Cheng il 18 Lug 2014
'b'=blue 'r'=red 'k'=black 'y'=yello 'c'=cyan
etc. plot documentation will also give how to create line dashes, markers, etc.

Accedi per commentare.

Più risposte (1)

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

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by