Plotting scatter plot in a FOR loop with different colors
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Siddhant Chandra
el 3 de Ag. de 2018
Respondida: dpb
el 3 de Ag. de 2018
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 comentarios
Respuesta aceptada
dpb
el 3 de Ag. de 2018
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!