Seaborn: How to increase the font size of the labels on the axes?

你。 提交于 2021-02-17 05:59:06

问题


Here's how I plot the heat map:

sns.heatmap(table, annot=True, fmt='g', annot_kws={'size':24})

The thing is, size set only the font size of the numbers inside the heatmap. Which parameter I should use in annot_kws to set the font size of the labels on the axes?

Thanks


回答1:


You cannot change those directly in the call to heatmap, but you can instruct matplotlib to change the font size either in plt.rcParams directly, or using a 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')



来源:https://stackoverflow.com/questions/65058295/seaborn-how-to-increase-the-font-size-of-the-labels-on-the-axes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!