我使用seaborn创建了一个热图,除了数字没有出现在正确的位置外,所有其他方法都起作用,似乎认为正方形的大小是它们的两倍。我搜索并阅读了很多内容,找不到任何问题。任何帮助表示赞赏。
def HeatMapDemo():
cm=[[1900,50,777],[1950,100,666],[2950,400,466]]
confusion=pd.DataFrame(cm,index=['A','B','C'],columns=['Predicted A','Predicted B','Predicted C'])
annot_kws = {"ha": 'left',"va": 'top'}
fig, ax = plt.subplots(figsize=(5,5))
sns.heatmap(confusion,annot=True,ax=ax,annot_kws=annot_kws,fmt='d', cmap="Greens", xticklabels=True, yticklabels=True)
plt.show()
HeatMapDemo()