jkf*_*jkf 5 python matplotlib heatmap seaborn
我正在使用带有自定义 yticklabels 的 Seaborn 热图功能。我的标签很长,即使我缩小字体大小,它们也会被截断。有没有办法允许更长的可见刻度标签?
ax = sns.heatmap(
pcolor_data,
xticklabels=day_columns,
yticklabels=line_sales_by_day['product_name'][0:n_skus].values,
annot=True,
cbar=True,
annot_kws={'size':10},
fmt='g',
cmap=cmap
)
Run Code Online (Sandbox Code Playgroud)
你有没有尝试过tight_layout选项matplotlib.pyplot?
ax = sns.heatmap(...)
ax.figure.tight_layout()
Run Code Online (Sandbox Code Playgroud)
或者,您可以subplots_adjust使用plt.figure实例的方法控制子图区域的边缘,您可以使用以下方法访问ax.figure.subplots_adjust():
ax = sns.heatmap(...)
ax.figure.subplots_adjust(left = 0.3) # change 0.3 to suit your needs.
Run Code Online (Sandbox Code Playgroud)