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

15 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by