gpt4 book ai didi

python - Seaborn 标记被截断

转载 作者:行者123 更新时间:2023-11-28 22:40:26 28 4
gpt4 key购买 nike

我正在使用带有自定义 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
)

最佳答案

您尝试过 tight_layout 吗? matplotlib.pyplot 中的选项?

ax = sns.heatmap(...)

ax.figure.tight_layout()

或者,您可以使用 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.

关于python - Seaborn 标记被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33660420/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com