seaborn热图未显示正确的位置,认为正方形是其两倍大

时间:2019-08-25 03:03:56

标签: python alignment seaborn heatmap figure

我使用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()

enter image description here

0 个答案:

没有答案
相关问题