Changing plot line colour with multiple data sets
조회 수: 10 (최근 30일)
이전 댓글 표시
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
채택된 답변
Michael
2022년 9월 12일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!