Filter löschen
Filter löschen

Adding colors to the plots in loop

7 Ansichten (letzte 30 Tage)
Najam us Saqib Fraz
Najam us Saqib Fraz am 26 Mai 2021
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Mai 2021
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

Weitere Antworten (0)

Kategorien

Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by