无法存储我的 Seaborn(热图)图的完整标签

Cannot store full labels of my Seaborn (heatmap) plot

我在 Seaborn 热图中存储标签时遇到问题。我的标签很长。当我使用 plt.show() 显示我的绘图时,我可以通过调整 canvas 的大小来查看完整的标签。但是,当我保存到文件时,只存储了标签的一小部分。我在 Seaborn 0.7.1:

中使用了以下代码
ax = sns.heatmap(some_matrix)
ax.set_yticklabels(labels=some_labels,rotation=0)
fig = ax.get_figure()
fig.savefig("my_file.png",dpi=600)

知道如何增加 canvas 的大小以便将完整的标签存储在我的 .png 文件中吗?减小字体大小可能不是一个好的解决方案,因为 Y 轴上有很多标签,导致标签变得不可读。

来自the docs

bbox_inches:
Bbox in inches. Only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure.

plt.plot([1, 2, 3], 'o-')
plt.yticks([1, 2, 3], ['a really really long label']*3)
plt.savefig('test1.png')

plt.savefig('test2.png', bbox_inches='tight')