After coming across this: Combining two heat maps in seaborn I did the following:
df = pd.DataFrame(np.random.rand(8,1), columns=list("A"))
df2 = pd.DataFrame(np.random.rand(8,1), columns=list("B"))
df3 = pd.DataFrame(np.random.rand(8,4), columns=list("CDEF"))
df4 = pd.DataFrame(np.random.rand(8,1), columns=list("G"))
df5 = pd.DataFrame(np.random.rand(8,1), columns=list("H"))
fig, (ax, ax2, ax3, ax4, ax5) = plt.subplots(figsize=(30, 10), ncols=5)
fig.subplots_adjust(wspace=0.01)
sb.heatmap(df, ax=ax, cbar=False, cmap = 'coolwarm_r', vmax = 30, vmin = 10, annot = True, fmt = '.2f', annot_kws = {'size':12})
sb.heatmap(df2, ax=ax2, cbar=False, cmap = 'coolwarm_r', vmax = 20, vmin = -10, annot = True, fmt = '.2f', annot_kws = {'size':12})
sb.heatmap(df3, ax=ax3, cbar=False, cmap = 'coolwarm_r', vmax = 50, vmin = 30, annot = True, fmt = '.2f', annot_kws = {'size':12})
sb.heatmap(df4, ax=ax4, cbar=False, cmap = 'coolwarm_r', vmax = 10, vmin = 5, annot = True, fmt = '.2f', annot_kws = {'size':12})
sb.heatmap(df5, ax=ax5, cbar=False, cmap = 'coolwarm_r', vmax = 8, vmin = 2, annot = True, fmt = '.2f', annot_kws = {'size':12})
ax2.set_yticks([])
ax3.set_yticks([])
ax4.set_yticks([])
ax5.set_yticks([])
ax.xaxis.tick_top() # Put x axis on top
ax2.xaxis.tick_top() # Put x axis on top
ax3.xaxis.tick_top() # Put x axis on top
ax4.xaxis.tick_top() # Put x axis on top
ax5.xaxis.tick_top() # Put x axis on top
fig.colorbar(ax5.collections[0], ax=ax5, location="right", use_gridspec=False, pad=0.2)
ax.tick_params(rotation=0) # Do not rotate y tick labels
plt.show()
But I get the following output where the width of each column of the heatmap is not the same:
Is there any way to resize each column (including those 4 columns from that one df in the middle) so that they're all of the same width?