How can I plot with different markers, linestyles and colors in a loop?
Ältere Kommentare anzeigen
I'm trying to plot frequency values from a loop over speed. I use multiple loops and it is not easy to plot with multiple markes, linestyles and colors. I found a function by Sébastien Martin in Matlab file exchange:
(See attachment)
It works if I try it with:
plot_styles(rand(10,6))
But as I need to plot with loops:
clear all,
close all;
clc;
n = (1:6);
F = rand(10,6);
figure
for j =1:10
plot_styles(n,F(j,:))
hold on
end
It did not give me different linestyles, colors and markers. Why? How can I make it work?
Thanks in advance!
Akzeptierte Antwort
Weitere Antworten (1)
Marco Riani
am 18 Dez. 2020
Please let me know if the code below helps
clear
close all;
clc;
n = (1:6);
F = rand(7,6);
figure
Markers={'o' '+' '*' '.' 'x' '_' '|' };
Colors={'r' 'g' 'b' 'c' 'm' 'y' 'k'};
LineTypes={'-' '--' ':' '-.' '-' '--' ':'};
hold on
for j =1:7
plot(n,F(j,:),'Marker',Markers{j},'Color',Colors{j},'LineStyle',LineTypes{j})
end
1 Kommentar
Eik Brüser
am 22 Dez. 2020
Kategorien
Mehr zu Graphics Object Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




