Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn showing scientific notation in heatmap for 3-digit numbers

People also ask

How do I turn off scientific notation in Seaborn?

To repress the scientific notation, use style="plain" in ticklabel_format() method.

What is FMT in SNS heatmap?

The annot only help to add numeric value on python heatmap cell but fmt parameter allows to add string (text) values on the cell. Here, we created a 2D numpy array which contains string values and passes to annot along with that pass a string value “s” to fmt.


According to the docs, the param fmt='.2g' is being applied because you've set annot=True so you can modify the format being applied to:

sns.heatmap(table2,annot=True,cmap='Blues', fmt='g')

According to the docs, the parameter fmt is set to .2g when annot=True. So, for example, if your data is float, you can use:

sns.heatmap(table2, annot=True, cmap='Blues', fmt='.3g')

By that, you're telling python to show 3 significant figures. To understand the "fmt" better, check out this answer: https://stackoverflow.com/a/65020192/4529605