matplotlib/seaborn: first and last row cut in half of heatmap plot

前端 未结 11 1171
猫巷女王i
猫巷女王i 2020-11-21 13:35

When plotting heatmaps with seaborn (and correlation matrices with matplotlib) the first and the last row is cut in halve. This happens also when I run this minimal code exa

11条回答
  •  花落未央
    2020-11-21 14:02

    Its a bug in the matplotlib regression between 3.1.0 and 3.1.1 You can correct this by:

    import seaborn as sns
    df_corr = someDataFrame.corr()
    ax = sns.heatmap(df_corr, annot=True) #notation: "annot" not "annote"
    bottom, top = ax.get_ylim()
    ax.set_ylim(bottom + 0.5, top - 0.5)
    

提交回复
热议问题