Plotting scatter plot in a FOR loop with different colors
16 次查看(过去 30 天)
显示 更早的评论
I am plotting a scatter plot from 'n'(=7,for now) Excel files. I am running a FOR loop to read through each Excel file and plot the scatter plot. But I am not able to change the color of the scatter plot each time the loop begins afresh. I basically want those 'n' scatter plots where each scatter plot is corresponding to a different Excel file (either filled circles or '*') in different colors, on the same graph. Can somebody please help me with this? Code is below:
for k=1:7
FileName2 = [' _xyz_',num2str(k),'.xls'];
filename3 =fullfile('ABC', FileName2);
[v,T,vT]=xlsread(filename3);
t=v(:,1);y=v(:,5);
sz = 25;
scatter(t,y,sz,'filled')
axis([115000 148000 35 160])
end
0 个评论
采纳的回答
dpb
2018-8-3
clrs=['r','g','b','c','m','y','k'];
for i=1:N
...
scatter(y,z,sz,c(i),'filled')
...
end
for the defined color mnemonics for red,green,blue,cyan,magenta,yellow,black. Rearrange order as wished; if want more or custom colors, use RGB triplets. Doc for 'linespec' shows examples.
You can do similar for symbols as well to iterate over them, of course.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!