赞
踩
成图如下:
a图为例子,纵坐标是1-12月,横坐标是不同的因子。如左下第一格表示的就是x1与AO因子在十二月的相关性。
(a/b/c是x1因子,d/e/f是x2因子)
首先要计算出每个相关系数(可以在SPSS中完成),然后将它们按矩阵型输入到excel中,如下:
接着在matlab中读入数据,直接画图:
- corr = readtable('AONAODA.xls','Sheet','Sheet2');
- A1 = table2array(corr(1:12,2:4));
- A2 = table2array(corr(1:12,7:9));
- A3 = table2array(corr(1:12,12:14));
- A4 = table2array(corr(15:26,2:4));
- A5 = table2array(corr(15:26,7:9));
- A6 = table2array(corr(15:26,12:14));
- % CMap=slanCM(102);
- CMap=slanCM(95);
-
-
- figure;
- sub1 = subplot(2,3,1);
- imagesc(A2);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- pos=set(sub1,'Position', [0.06 0.58 0.22 0.38]); %设置位置
- txt = {'(a) 1984-2000'};
- text(0.1,1,txt)
-
- % yticklabels({'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'});
-
- sub2 = subplot(2,3,2);
- imagesc(A3);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- pos=set(sub2,'Position', [0.36 0.58 0.22 0.38]);
- txt = {'(b) 2001-2022'};
- text(0.1,1,txt)
-
- sub3 = subplot(2,3,3);
- imagesc(A1);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- txt = {'(c) 1984-2022'};
- text(0.1,1,txt)
- pos=set(sub3,'Position', [0.66 0.58 0.22 0.38]);
-
- sub4 = subplot(2,3,4);
- imagesc(A5);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- pos=set(sub4,'Position', [0.06 0.1 0.22 0.38]);
- txt = {'(d) 1984-2000'};
- text(0.1,1,txt)
-
- sub5 = subplot(2,3,5);
- imagesc(A6);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- pos=set(sub5,'Position', [0.36 0.1 0.22 0.38]);
- txt = {'(e) 2001-2022'};
- text(0.1,1,txt)
-
- sub6=subplot(2,3,6);
- imagesc(A4);
- caxis([-1 1]);
- xticklabels({'AO','NAO','DA'});
- yticks([1:2:12]);
- yticklabels({'Jan','Mar','May','Jul','Sep','Nov'});
- pos=set(sub6,'Position', [0.66 0.1 0.22 0.38]);
- txt = {'(f) 1984-2022'};
- text(0.1,1,txt)
-
- colormap(CMap);
-
-
- h=colorbar('eastoutside','fontsize',12);
- set(get(h,'Title'),'string','Corr','fontsize',9)
- set(h,'YTick',-1:1:1,'fontsize',9);%设置colorbar单位
- pos3=set(h,'Position', [0.92 0.1 0.022 0.85]); %设置colorbar位置
-
-
上面的代码大部分都是重复的,只要弄懂第一个子图怎么画,后面的改变量就行。
(CMap是我下的颜色库,也可以用matlab自带的)
另外,多子图的colorbar的设置需要在最后单独写几行代码,可根据自己需求更改。
祝大家画出好看的图。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。