Changing plot line colour with multiple data sets
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jrz
el 12 de Sept. de 2022
Comentada: jrz
el 14 de Sept. de 2022
I have a plot with 9 different data sets but 2 are coming out as the same color.
plot(xcUpper,Cp0U,'-o','k','linewidth', 2)
hold on
plot(xcUpper,Cp5U,'-o','linewidth', 2)
plot(xcUpper,Cp10U,'-o','linewidth', 2)
plot(xcUpper,Cp15U,'-o','linewidth', 2)
plot(xcUpper,Cp20U,'-o','linewidth', 2)
plot(xcUpper,CpM5U,'-o','linewidth', 2)
plot(xcUpper,CpM10U,'-o','linewidth', 2)
plot(xcUpper,CpM15U,'-o','linewidth', 2)
plot(xcUpper,CpM20U,'-o','linewidth',2)
title('NACA23012 Cp Distribution (Upper Surface)')
grid on
grid minor
xlabel('x/c (m)','FontSize',18)
ylabel('Pressure Coefficient','FontSize', 18)
box on
set(gca,'GridLineStyle','-')
set(gca,'MinorGridLineStyle','-')
set(gca,'GridColor','k')
set(gca,'MinorGridColor','k')
legend('\alpha = 0^\circ','\alpha = 5^\circ','\alpha = 10^\circ','\alpha = 15^\circ'...
,'\alpha = -5^\circ','\alpha = -10^\circ','\alpha = -15^\circ','\alpha = -20^\circ')
ax = gca;
ax.FontSize = 15; % Font Size of 15
How can ensure each data set has a different color?
0 comentarios
Respuesta aceptada
Michael
el 12 de Sept. de 2022
Create a color map and then give each one a distinct color.
figure;
thecolors = parula(9);
for i = 1:9
plot(rand(5,1),rand(5,1),'Color',thecolors(i,:),'DisplayName',['Line Number = ',num2str(i)]);
hold on;
end
legend('Location','best')
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh 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!