-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMM_plt_tseries.py
More file actions
61 lines (50 loc) · 2.51 KB
/
MMM_plt_tseries.py
File metadata and controls
61 lines (50 loc) · 2.51 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
import numpy as np
import matplotlib.pyplot as plt
from MidPointNorm import *
def MMM_plt_tseries(data, x, y, z, rows, cols, xlabel, ylabel, sp_titles, cb_label, zint, filename, d2_c=0):
f, axarr = plt.subplots(rows, cols, sharex=True, sharey=True, figsize=(12,12), dpi=200)
#plt.setp(axarr.flat, aspect=1.0, adjustable='box-forced')
# Assign labels
xlabel = xlabel
ylabel = ylabel
cb_label = cb_label
f.text(0.5, 0.04, '%s' % (xlabel), fontsize=18, ha='center')
f.text(0.06, 0.5, '%s' % (ylabel), fontsize=18, va='center', rotation='vertical')
# Ticks
major_ticksx = np.arange(np.floor(x[0]), np.ceil(x[-1]), 20)
minor_ticksx = np.arange(np.floor(x[0]), np.ceil(x[-1]), 5)
major_ticksy = np.arange(np.floor(y[0]), np.ceil(y[-1]), 20)
minor_ticksy = np.arange(np.floor(y[0]), np.ceil(y[-1]), 5)
# Subplots
m=0
for i in xrange(rows):
for j in xrange(cols):
ax = axarr[i,j].pcolormesh(x, y, data[m*zint,:,:], cmap='RdBu_r', norm=MidPointNorm(midpoint=0.), vmin=np.min(data))
axarr[i,j].axis('tight')
axarr[i,j].set_title('%s %0.1f' % (sp_titles, z[m*zint]), fontsize=10)
axarr[i,j].set_xticks(major_ticksx)
axarr[i,j].set_yticks(major_ticksy)
axarr[i,j].set_xticks(minor_ticksx, minor=True)
axarr[i,j].set_yticks(minor_ticksy, minor=True)
axarr[i,j].tick_params(axis='both', labelsize=8, pad=10)
if (d2_c!=0):
lvls = [-5,0,5,10,15]
ax2 = axarr[i,j].contour(d2_c[1], d2_c[0], d2_c[2], lvls, colors='k')
m=m+1
# Colorbar creation and placement
if (np.max(data)<=0.09):
f.subplots_adjust(right=0.8)
cbar_ax = f.add_axes([0.85, 0.1, 0.04, 0.8]) # [h_plc, v_plc, h_size, v_size]
cb = f.colorbar(ax, cax=cbar_ax, format='%.2e', extend='both')
cb.set_label('%s' % (cb_label), fontsize=16) # colorbar label
elif (np.max(data)<=100) & (np.min(data)>=0.1):
f.subplots_adjust(right=0.8)
cbar_ax = f.add_axes([0.85, 0.1, 0.04, 0.8]) # [h_plc, v_plc, h_size, v_size]
cb = f.colorbar(ax, cax=cbar_ax, format='%.1f', extend='both')
cb.set_label('%s' % (cb_label), fontsize=16) # colorbar label
else:
f.subplots_adjust(right=0.8)
cbar_ax = f.add_axes([0.85, 0.1, 0.04, 0.8]) # [h_plc, v_plc, h_size, v_size]
cb = f.colorbar(ax, cax=cbar_ax, format='%.0f', extend='both')
cb.set_label('%s' % (cb_label), fontsize=16) # colorbar label
plt.savefig("%s" % (filename), bbox_inches='tight', dpi=200)