How can I plot with different markers, linestyles and colors in a loop?
Show older comments
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!
Accepted Answer
More Answers (1)
Marco Riani
on 18 Dec 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 Comment
Eik Brüser
on 22 Dec 2020
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



