Warm tip: This article is reproduced from serverfault.com, please click

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

发布于 2020-11-29 08:31:39

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

Questioner
Elimination
Viewed
0
Diziet Asahi 2020-11-29 20:18:20

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')

enter image description here