Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto adjust font size in seaborn heatmap

when using seaborn heatmap, is there a way to auto-adjust the font size for it to fit exactly inside the squares? for example in:

sns.heatmap(corrmat, vmin=corrmat.values.min(), vmax=1, square=True, cmap="YlGnBu",          linewidths=0.1, annot=True, annot_kws={"size":8})   

here the size is set in "annot_kws".

like image 918
Gabriel Avatar asked Oct 13 '15 13:10

Gabriel


People also ask

How do I change the font size in Seaborn heatmap?

Consider calling sns. set(font_scale=1.4) before plotting your data. This will scale all fonts in your legend and on the axes. Of course, adjust the scaling to whatever you feel is a good setting.


1 Answers

You can also do:

sns.heatmap(corrmat, vmin=corrmat.values.min(), vmax=1, square=True, cmap="YlGnBu", linewidths=0.1, annot=True, annot_kws={"fontsize":8})   
like image 113
dex314 Avatar answered Sep 21 '22 06:09

dex314