【发布时间】:2021-03-11 11:21:52
【问题描述】:
这是我绘制热图的方法:
sns.heatmap(table, annot=True, fmt='g', annot_kws={'size':24})
问题是,size 仅设置热图中数字的字体大小。我应该在annot_kws 中使用哪个参数来设置轴上标签的字体大小?
谢谢
【问题讨论】:
标签: python-3.x matplotlib seaborn
这是我绘制热图的方法:
sns.heatmap(table, annot=True, fmt='g', annot_kws={'size':24})
问题是,size 仅设置热图中数字的字体大小。我应该在annot_kws 中使用哪个参数来设置轴上标签的字体大小?
谢谢
【问题讨论】:
标签: python-3.x matplotlib seaborn
您不能直接在对heatmap 的调用中更改它们,但您可以指示matplotlib 更改字体大小in plt.rcParams directly 或使用context manager:
uniform_data = np.random.rand(10, 12)
plt.figure()
with plt.style.context({'axes.labelsize':24,
'xtick.labelsize':8,
'ytick.labelsize':16}):
ax = sns.heatmap(uniform_data, annot=True, fmt='.1f', annot_kws={'size':6})
ax.set_xlabel('x label')
【讨论】: