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

18 ビュー (過去 30 日間)
sermet
sermet 2014 年 7 月 18 日
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 件のコメント
Seetha Rama Raju Sanapala
Seetha Rama Raju Sanapala 2014 年 7 月 18 日
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.

サインインしてコメントする。

採用された回答

Joseph Cheng
Joseph Cheng 2014 年 7 月 18 日
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 件のコメント
Joseph Cheng
Joseph Cheng 2014 年 7 月 18 日
'b'=blue 'r'=red 'k'=black 'y'=yello 'c'=cyan
etc. plot documentation will also give how to create line dashes, markers, etc.

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 18 日
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])

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by