\n","author":{"@type":"Person","name":"PieCot"},"upvoteCount":3}}}
Reputation: 574
I have a code that plots multiple plots - a heatmap and a barplot in a single plot in Seaborn. However, both plots are sized equally, i.e, one half of overall figure is heatmap, other half is barplot. Is there a way to control individual plot sizes such that heatmap occupies 75% of the plot size while barplot occupies only 25% of the plot?
Reference Code:
ig, ax = plt.subplots(1, 2, figsize=(7, 5))
heatmap = np.random.uniform(0, 1, size=(12, 12))
sns.heatmap(heatmap_scores, linewidth=0.5, cmap="OrRd", ax=ax[0])
ax[0].set_xlabel('Head')
ax[0].set_ylabel('Layer')
ax[0].set_title('Attention Heatmap')
x = np.mean(heatmap_scores, axis=1)
y = np.arange(0, 12)
sns.barplot(x=x, y=y, ax=ax[1], orient='h', color='r', dodge=False)
ax[1].set_title('Layer Average')
ax[1].set(yticklabels=[])
plt.savefig('fig.png')
plt.close()
Upvotes: 2
Views: 1105