Adding colors to the plots in loop

7 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by