Seaborn showing scientific notation in heatmap for 3-digit numbers

cigrainger picture cigrainger · Apr 15, 2015 · Viewed 51.4k times · Source

I'm creating a heatmap from a pandas pivot_table as below:

table2 = pd.pivot_table(df,values='control',columns='Year',index='Region',aggfunc=np.sum)
sns.heatmap(table2,annot=True,cmap='Blues')

It creates a heat map as shown below. You can see the numbers are not huge (max 750), but it's showing them in scientific notation. If I view the table itself this is not the case. Any idea on how I could get it to show the numbers in plain notation?

Heatmap

Answer

EdChum picture EdChum · Apr 15, 2015

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