Seaboarnでheatmapを表示させた時の数字を1.5e+02→150に変更[Python]

7月 26, 2020

修正前

import matplotlib.pyplot as plt
import seaborn as sns
confusion = calc_confusion(all_prediction["A"], all_prediction["B"])
df = pd.DataFrame(data=confusion, index=['0', '1', '2', '3'], columns=['0', '1', '2', '3'])
plt.figure()
sns.heatmap(confusion, annot=True)
plt.xlabel('A')
plt.ylabel('B')

f:id:Vastee:20191004174059p:plain

修正後

sns.heatmapの引数にfmt='d'を与えた.

import matplotlib.pyplot as plt
import seaborn as sns
confusion = calc_confusion(all_prediction["A"], all_prediction["B"])
df = pd.DataFrame(data=confusion, index=['0', '1', '2', '3'], columns=['0', '1', '2', '3'])
plt.figure()
sns.heatmap(confusion, annot=True, fmt='d')
plt.xlabel('A')
plt.ylabel('B')

f:id:Vastee:20191004174207p:plain

Python

Posted by vastee