2

I am converting confusion matrix to heatmap. The code to convert the dataframe into heatmap is giving numbers in scientific notation on the graph

I dont know what to do because when I display the df everything is fine. And I dont know how to tell seaborn to stop doing something like this

```python
df_cm = pd.DataFrame(arr, range(2),range(2))
sns.set(font_scale=1)#for label size
sns.heatmap(df_cm, annot=True,annot_kws={"size": 10},)
```

The data frame is like this: 2 rows 2 columns

847 . 22

114 . 17

But in heat map what comes is

8.5e+2 . 22

1.1e+2 . 17

Community
  • 1
  • 1
MagicBeans
  • 343
  • 1
  • 5
  • 18

1 Answers1

6

change the format using the fmt parameter, to get integers:

sns.heatmap(df_cm, annot=True,annot_kws={"size": 10},fmt="d")

to get float with 1 decimal

sns.heatmap(df_cm, annot=True,annot_kws={"size": 10},fmt=".1f")

Juan Carlos Ramirez
  • 2,054
  • 1
  • 7
  • 22