Seaborn: heatmap annotation font size

Created on 22 Jan 2015  路  6Comments  路  Source: mwaskom/seaborn

I am creating a heatmap with sns.heatmap() but couldn't find a way to set the size of the labels inside the boxes when we set annot=True, is it possible to make the font smaller ?

Thanks

Most helpful comment

Use the annot_kws parameter, e.g.

sns.heatmap(x, annot=True, annot_kws={"size": 20})

All 6 comments

Use the annot_kws parameter, e.g.

sns.heatmap(x, annot=True, annot_kws={"size": 20})

of course !

Thanks

Is there any simple way to make the those columns' name on both axes bigger and rotate those on the x-axis?
I could use sns.set(font_scale=1.8) to change the font size but then I have to pass annot_kws={"size": 20} argument to keep the annot small, so I wonder if there is an easy way to do that and rotate as well.

sns.set(font_scale=1.8) woked thanks

Can we have different colours for the xticklabels?

@siddhant-doshi
you can simply use matplotlib axes methods for it.

import numpy as np; np.random.seed(0)
import seaborn as sns; sns.set_theme()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data)

ax.tick_params(axis='x', colors='red')

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanHomann picture JanHomann  路  3Comments

ConstantinoSchillebeeckx picture ConstantinoSchillebeeckx  路  4Comments

wenhaosun picture wenhaosun  路  3Comments

stonebig picture stonebig  路  4Comments

TDaltonC picture TDaltonC  路  3Comments