I m trying to organize and ajust my three subplots obtained with tripcolor od Delaunay triangulation. The problem is i cant use the function : plt.tight_layout(pad=0.5, w_pad=2.5, h_pad=2.0) to set the windows size, it doesnt work in this case. The result corresponds to :
I would like to have square form for the windows...My code is :
import matplotlib.tri as tr
triang = tr.Triangulation(Xini, Yini)
xmid = Xini[triang.triangles].mean(axis=1)
ymid = Yini[triang.triangles].mean(axis=1)
plt.figure()
ax1 = plt.subplot(131) # creates first axis
i1 =ax1.tripcolor(triang, Epst_eq2, shading='flat', cmap=plt.cm.hot)
ax1.set_xlim([-2.5,2.5])
ax1.set_ylim([-2.5,2.5])
# plt.title('tripcolor of Delaunay triangulation, flat shading')
plt.colorbar(i1,ax=ax1,ticks=np.linspace(0,0.005,3))
ax2 = plt.subplot(132) # creates first axis
ax2.tripcolor(triang, Epst_eq3, shading='flat', cmap=plt.cm.hot)
ax2.set_xlim([-2.5,2.5])
ax2.set_ylim([-2.5,2.5])
ax3 = plt.subplot(133) # creates first axis
ax3.tripcolor(triang, Epst_eq4, shading='flat', cmap=plt.cm.hot)
ax3.set_xlim([-2.5,2.5])
ax3.set_ylim([-2.5,2.5])
plt.savefig('test2.png',dpi=100)
plt.show()
Finally i used gridspec and i can modify easily the size!
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure(figsize=(16, 6))
gs = gridspec.GridSpec(1, 3,width_ratios=[1.2,1,1])
ax1 = plt.subplot(gs[0])
i1 =ax1.tripcolor(triang, Epst_eq2, shading='flat', cmap=plt.cm.hot)
ax1.set_xlim([-2.5,2.5])
ax1.set_ylim([-2.5,2.5])
# plt.title('tripcolor of Delaunay triangulation, flat shading')
plt.colorbar(i1,ax=ax1,ticks=np.linspace(0,0.005,3))
ax2 = plt.subplot(gs[1])
ax2.tripcolor(triang, Epst_eq3, shading='flat', cmap=plt.cm.hot)
ax2.set_xlim([-2.5,2.5])
ax2.set_ylim([-2.5,2.5])
ax3 = plt.subplot(gs[2])
ax3.tripcolor(triang, Epst_eq4, shading='flat', cmap=plt.cm.hot)
ax3.set_xlim([-2.5,2.5])
ax3.set_ylim([-2.5,2.5])
plt.tight_layout()
plt.savefig('test2.png',dpi=100)
plt.show()