搞来搞去,又是一小时,记录一下
只需要增加 fmt 参数即可
sns.heatmap(cm, annot=True, fmt='.20g', cmap=plt.cm.Blues)
完整例子,先显示默认的,再使用去掉科学计数法的
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
cm = np.random.randint(0, 30000, [4, 4])
# 默认 fmt 参数
f = plt.figure(1, clear=True)
sns.heatmap(cm, annot=True, cmap=plt.cm.Blues)
f.show()
# plt.pause(5)
# 修改后 fmt 参数
f = plt.figure(2, clear=True)
sns.heatmap(cm, annot=True, fmt='.20g', cmap=plt.cm.Blues)
f.show()
plt.pause(5)