How can I produce 1x15 subplots where the first and second columns are filled contour and the third column will have two stacked horizontal line plots in each of the rows?
The code below is an example but I want the line plots in the third column to be in different panels instead of an overplot.
# In[10]:
gs = gridspec.GridSpec(7, 15, width_ratios=[1, 1, 1, 1, 1, 1, 0.2, 1, 1, 1, 1, 1, 1, 1, 1])
gs.update(wspace=0.1, hspace=0.15)
fig = plt.figure(figsize = (8, 12))
clevs = np.linspace(-1.02, 1.02, 101)
# HW Pattern
# Merge columns 1 to 3
gs_merged1 = gs[:, 0:3]
ax1 = plt.subplot(gs_merged1)
m1 = Basemap(ax=ax1, projection='cyl', llcrnrlon=min(lon), llcrnrlat=min(lat), urcrnrlon=max(lon), urcrnrlat=max(lat))
m1.contourf(x1, y1, np.transpose(U1_norm), clevs, cmap=plt.cm.jet, extend='both', vmax=1.0, vmin=-1.0)
m1.drawcoastlines()
m1.drawparallels(parallels, labels=[1,0,0,0], fontsize=12)
m1.drawmeridians(meridians, labels=[1,0,0,1], fontsize=12)
plt.xlabel('Longitude ($^{\circ}$)', fontsize=15, labelpad=18.)
plt.ylabel('Latitude ($^{\circ}$)', fontsize=15, labelpad=30.)
ax1.set_title('HW Mode 1', fontweight="bold", color = 'b')
ax1.text(0.98, 1.01, f'{Hc[j]} km', transform=ax1.transAxes, ha='right', fontsize=12, color = 'r', weight='bold')
# Merge columns 4 to 6
gs_merged2 = gs[:, 3:6]
ax2 = plt.subplot(gs_merged2)
m2 = Basemap(ax=ax2, projection='cyl', llcrnrlon=min(lon), llcrnrlat=min(lat), urcrnrlon=max(lon), urcrnrlat=max(lat))
cs2 = m2.contourf(x2, y2, np.transpose(V1_norm), clevs, cmap=plt.cm.jet, extend='both', vmax=1.0, vmin=-1.0)
m2.drawcoastlines()
m2.drawparallels(parallels, labels=[0,0,0,0], fontsize=12)
m2.drawmeridians(meridians, labels=[0,0,0,1], fontsize=12)
plt.xlabel('Longitude ($^{\circ}$)', fontsize=15, labelpad=18.)
ax2.set_title('T_{amp} Mode 1', fontweight="bold", color = 'b')
ax2.set_ylabel('')
ax2.text(0.98, 1.01, f'{Hc[j]} km', transform=ax2.transAxes, ha='right', fontsize=12, color = 'r', weight='bold')
gs.update(wspace=0.6)
# Create colorbar in column 11
gs11 = gs[:, 6]
ax4 = plt.subplot(gs11)
cb = plt.colorbar(cs2, cax=ax4, shrink=0.6, extend='both', pad="10%", ticks=np.arange(-1.01, 1.03, 0.2)) # Assuming ax7_9 has the same color map as ax1_3 and ax4_6
cb.ax.set_position([0.82, 0.15, 0.02, 0.3])
cb.set_label('SVD', fontsize=14)
# Switch-off the axes in column 7
ax3 = plt.subplot(gs[:, 7:8])
ax3.axis('off')
# gs.update(wspace=2)
# EC1
ax2 = fig.add_subplot(gs[2:5, 8:])
ax2.plot(days, a1_norm, label='HW')
ax2.plot(days, b1_norm, label='T_{amp}')
r = np.corrcoef(a1[:, 0], b1[:, 0])[0, 1]
ax2.set_title('Expansion Coefficients: SFC = '+ str(round(scf[0], 2)) + ', R = ' + str(round(r, 2)))
ax2.legend()
ax2.set_ylim([-3, 3])
ax2.set_ylabel('SC1', fontsize=14)
ax2.format_xdata = mdates.DateFormatter('%Y')
fig.autofmt_xdate()
There are two things I need to do.
(1) I want to put a x-axis label on the line plot on the third column
(2) I want reduce the height of the colorbar.