[英]Python-How to have the axis ticks in both top and bottom, left and right of sns.heatmap
我正在嘗試使用sns.heatmap函數繪制一個大的熱圖。 但是,由於地圖太大,因此很難找到帶有相應行和列的xtick標簽或ytick標簽。 我可以同時在頂部添加xtick和xlabels,也可以在右側添加ytick和ylabel嗎?
我嘗試了許多不同的方法。 但是他們都沒有工作。
可以使用matplotlib中的tick_params
放置所有面的軸刻度
#Get sample correlation data to plot something. 'data' is a dataframe
corr=data.corr()
#Create Heatmap
axr = sns.heatmap(corr,cmap="coolwarm", annot=True, linewidths=.5,cbar=False)
#Set all sides
axr.tick_params(right=True, top=True, labelright=True, labeltop=True,rotation=0)
#Rotate X ticks
plt.xticks(rotation='vertical')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.