Reputation: 779
I have a subplot with the grid (1X7). I am trying to adjust the spacing between the two subplots.
I used the subplots_adjust option with the left and right spacing specified. But it does not seem to work. Below is the main code for subplots
fig, axs = plt.subplots(1,7,sharey=True,figsize=(12,10))
fig.subplots_adjust(left= 0.1, right=0.9, bottom = 0.1, top = 0.9, wspace=0.2)
cs = axs[0].contour(xx,yy,tm_true.T, 40, cmap='inferno', interpolation='bilinear')
axs[0].text(0.4, -0.04, '(a)', transform=axs[0].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[1].contour(xx,yy,tm_romgp.T, 40, cmap='inferno', interpolation='bilinear')
axs[1].text(0.4, -0.04, '(b)', transform=axs[1].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[2].contour(xx,yy,tm_s1.T, 40, cmap='inferno', interpolation='bilinear')
axs[2].text(0.4, -0.04, '(c)', transform=axs[2].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[3].contour(xx,yy,tm_e1.T, 40, cmap='inferno', interpolation='bilinear')
axs[3].text(0.4, -0.04, '(d)', transform=axs[3].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[4].contour(xx,yy,tm_l1.T, 40, cmap='inferno', interpolation='bilinear')
axs[4].text(0.4, -0.04, '(e)', transform=axs[4].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[5].contour(xx,yy,tm_b21.T, 40, cmap='inferno', interpolation='bilinear')
axs[5].text(0.4, -0.04, '(f)', transform=axs[5].transAxes, fontsize=16, fontweight='bold', va='top')
cs = axs[6].contour(xx,yy,tm_b31.T, 40, cmap='inferno', interpolation='bilinear')
axs[0].text(0.4, -0.04, '(g)', transform=axs[6].transAxes, fontsize=16, fontweight='bold', va='top')
fig.tight_layout()
fig.subplots_adjust(bottom=0.08)
cbar_ax = fig.add_axes([0.22, -0.05, 0.6, 0.04])
fig.colorbar(cs, cax=cbar_ax, orientation='horizontal')
plt.show()
fig.savefig("temp_twoleg.png", bbox_inches = 'tight')
```[![enter image description here][1]][1]
[1]: https://i.sstatic.net/JFRkt.png
Upvotes: 1
Views: 4619
Reputation: 339220
Because tight_layout
will overwrite any settings to the subplot parameters, it does not make sense to call tight_layout
after subplots_adjust
. Easiest is to just remove the tight_layout
line from your script.
Upvotes: 1