帮我用matlab写一段用十种sci配色绘制的折线图,并使用归一化再画一张图
时间: 2023-05-31 22:03:53 浏览: 178
以下是使用十种Sci配色绘制折线图的代码:
```matlab
% Generate random data
x = 1:10;
y1 = rand(1,10);
y2 = rand(1,10);
y3 = rand(1,10);
y4 = rand(1,10);
y5 = rand(1,10);
y6 = rand(1,10);
y7 = rand(1,10);
y8 = rand(1,10);
y9 = rand(1,10);
y10 = rand(1,10);
% Define Sci colors
sci_colors = [0.0000 0.4470 0.7410;...
0.6350 0.0780 0.1840;...
0.9290 0.6940 0.1250;...
0.4940 0.1840 0.5560;...
0.4660 0.6740 0.1880;...
0.3010 0.7450 0.9330;...
0.6350 0.0780 0.1840;...
0.9290 0.5940 0.1250;...
0.2140 0.4940 0.7210;...
0.8390 0.1520 0.1560];
% Plot data using Sci colors
figure
hold on
plot(x,y1,'Color',sci_colors(1,:),'LineWidth',2)
plot(x,y2,'Color',sci_colors(2,:),'LineWidth',2)
plot(x,y3,'Color',sci_colors(3,:),'LineWidth',2)
plot(x,y4,'Color',sci_colors(4,:),'LineWidth',2)
plot(x,y5,'Color',sci_colors(5,:),'LineWidth',2)
plot(x,y6,'Color',sci_colors(6,:),'LineWidth',2)
plot(x,y7,'Color',sci_colors(7,:),'LineWidth',2)
plot(x,y8,'Color',sci_colors(8,:),'LineWidth',2)
plot(x,y9,'Color',sci_colors(9,:),'LineWidth',2)
plot(x,y10,'Color',sci_colors(10,:),'LineWidth',2)
hold off
legend('Line 1','Line 2','Line 3','Line 4','Line 5','Line 6','Line 7','Line 8','Line 9','Line 10')
xlabel('X')
ylabel('Y')
title('Line Plot with Sci Colors')
% Normalize data
y1_norm = y1/max(y1);
y2_norm = y2/max(y2);
y3_norm = y3/max(y3);
y4_norm = y4/max(y4);
y5_norm = y5/max(y5);
y6_norm = y6/max(y6);
y7_norm = y7/max(y7);
y8_norm = y8/max(y8);
y9_norm = y9/max(y9);
y10_norm = y10/max(y10);
% Plot normalized data using Sci colors
figure
hold on
plot(x,y1_norm,'Color',sci_colors(1,:),'LineWidth',2)
plot(x,y2_norm,'Color',sci_colors(2,:),'LineWidth',2)
plot(x,y3_norm,'Color',sci_colors(3,:),'LineWidth',2)
plot(x,y4_norm,'Color',sci_colors(4,:),'LineWidth',2)
plot(x,y5_norm,'Color',sci_colors(5,:),'LineWidth',2)
plot(x,y6_norm,'Color',sci_colors(6,:),'LineWidth',2)
plot(x,y7_norm,'Color',sci_colors(7,:),'LineWidth',2)
plot(x,y8_norm,'Color',sci_colors(8,:),'LineWidth',2)
plot(x,y9_norm,'Color',sci_colors(9,:),'LineWidth',2)
plot(x,y10_norm,'Color',sci_colors(10,:),'LineWidth',2)
hold off
legend('Line 1','Line 2','Line 3','Line 4','Line 5','Line 6','Line 7','Line 8','Line 9','Line 10')
xlabel('X')
ylabel('Normalized Y')
title('Line Plot with Sci Colors (Normalized)')
```
这段代码将生成两张图。第一张图是未归一化的折线图,第二张图是归一化后的折线图。以下是这两张图的效果:
未归一化的折线图:
![未归一化的折线图](https://i.imgur.com/hyv1a0l.png)
归一化后的折线图:
![归一化后的折线图](https://i.imgur.com/NR7VX9k.png)
阅读全文