Adding colors to the plots in loop

19 ビュー (過去 30 日間)
Najam us Saqib Fraz
Najam us Saqib Fraz 2021 年 5 月 26 日
I have a loop that do a function forteen times.Each time it averages some values and makes a plot.It means there are are fourteen plots at on one graph.I am having problem with the colors of these plots.I want to give each plot a black color line with some squares,or cross,or diamonds etc.I made a new vector cotaining all the names of the color and each time it should select one of the color.Some of my code is shown below
colors=['k+:','k.-','kx-','k+-','k*-','ks-','kd-','kv-','k^-','k<-','k>-','kp-','kh-','k--'];
for k=1:1:length(BigMa_1); # Length of BigMa_1 is 14
code
plot(vector./100,yi,colors(k),'DisplayName',['Step No',' ',num2str(k)],'LineWidth',1);
end
Problem is it does not display the black lines.It shows some weird shapes.I am stuck here for two months.Can any one help me in this regard.I need to produces black line with different symbols like plus,square,star ets data poinst

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 26 日
colors = {'k+:','k.-','kx-','k+-','k*-','ks-','kd-','kv-','k^-','k<-','k>-','kp-','kh-','k--'};
for k=1:1:length(BigMa_1); % Length of BigMa_1 is 14
code
plot(vector./100,yi,colors{k},'DisplayName',['Step No',' ',num2str(k)],'LineWidth',1);
end
  1 件のコメント
Najam us Saqib Fraz
Najam us Saqib Fraz 2021 年 5 月 26 日
Thanks Alot....Never thought It so simple...

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by