Missing labels in Matplotlib correlation heatmap

前端 未结 1 1137
慢半拍i
慢半拍i 2021-01-19 01:56

I\'m playing around with the abalone dataset from UCI\'s machine learning repository. I want to display a correlation heatmap using matplotlib and imshow.

The first

相关标签:
1条回答
  • 2021-01-19 02:39

    To get your labels back, you can force matplotlib to use enough xticks so that all your labels can be shown. This can be done by adding

    ax1.set_xticks(np.arange(len(labels)))
    ax1.set_yticks(np.arange(len(labels)))
    

    before your statements ax1.set_xticklabels(labels,rotation=90, fontsize=10) and ax1.set_yticklabels(labels,fontsize=10).

    This results in the following plot:

    0 讨论(0)
提交回复
热议问题