-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmultiple_subplots.py
More file actions
63 lines (52 loc) · 2.74 KB
/
multiple_subplots.py
File metadata and controls
63 lines (52 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
fig,ax = plt.subplots(ncols=3,nrows=3, figsize=(11.69,8.27), subplot_kw={'projection': ccrs.PlateCarree()})
cnt = 0
for i in range(3):
for j in range(3):
#print(pr_aer[0].sel(time=))
tci_control = compute_tci(mrsos_control[cnt].sel(time=mrsos_control[cnt].time.dt.month.isin([5,6, 7, 8,9])), \
hfls_control[cnt].sel(time=mrsos_control[cnt].time.dt.month.isin([5,6, 7, 8,9])))
tci_aer = compute_tci(mrsos_aer[cnt].sel(time=mrsos_aer[cnt].time.dt.month.isin([5,6, 7, 8,9])), \
hfls_aer[cnt].sel(time=mrsos_aer[cnt].time.dt.month.isin([5,6, 7, 8,9])))
# tci_control = compute_tci(mrsos_control[cnt], hfls_control[cnt])
# tci_aer = compute_tci(mrsos_aer[cnt], hfls_aer[cnt])
diff_ = tci_aer - tci_control
#diff_ = (pr_aer[cnt]-pr_control[cnt]).sel(time=pr_aer[cnt].time.dt.month.isin([5,6, 7, 8,9])).mean(dim='time')*86400
diff_.sel(lon=slice(60,100),lat=slice(5,40)).plot(ax=ax[i,j], \
cmap='BrBG', extend='both', vmin=-10, vmax=10)
ax[i,j].coastlines()
ax[i,j].set_title(titles[cnt])
cnt=cnt+1
#print(i,j)
if cnt>=6:
break
fig.delaxes(ax[2,1])
fig.delaxes(ax[2,2])
fig.patch.set_linewidth(10)
fig.patch.set_edgecolor('cornflowerblue')
fig.suptitle('Terrestrial coupling index (Dirmeyer et al 2011) (AER - Control) MJJAS', size=16)
############### Also
data = [ds_trmm.r.sel(lon=slice(0,150), lat=slice(-20,60)).mean(dim='time'), \
ds_anthrop.sel(lon=slice(0,150), lat=slice(60,-20)).mean(dim='time'), \
ds_no_anthrop.sel(lon=slice(0,150), lat=slice(60,-20)).mean(dim='time')]
fig,ax = plt.subplots(ncols=2,nrows=3, figsize=(11.69,8.27), subplot_kw={'projection': ccrs.PlateCarree()})
fig.delaxes(ax[1,1])
#ax_ = [ax1, ax2, ax3, ax4]
tit_ = ['TRMM', 'Anthrop', 'No-Anthrop']
cnt=0
for i_fig in range(2):
for j_fig in range(2):
if cnt>2:
break
data[cnt].plot(ax=ax[i_fig, j_fig], cmap='BrBG', vmin=0, vmax=15)
ax[i_fig, j_fig].set_title(tit_[cnt])
ax[i_fig,j_fig].coastlines()
cnt=cnt+1
fig.patch.set_linewidth(10)
fig.patch.set_edgecolor('cornflowerblue')
left_ = 0.125 # the left side of the subplots of the figure
right_ = 0.9 # the right side of the subplots of the figure
bottom_ = 0.1 # the bottom of the subplots of the figure
top_ = 0.9 # the top of the subplots of the figure
wspace_ = 0.5 # the amount of width reserved for blank space between subplots
hspace_ = 0.1 # the amount of height reserved for white space between subplots
plt.subplots_adjust(left=left_, bottom=bottom_, right=right_, top=top_, wspace=wspace_, hspace=hspace_)