本文介绍了如何对齐Seaborn中的xlabel和ylabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制特征的热图,但x和y轴上的特征名称彼此一致.因此,如何垂直对齐x轴要素名称和水平对齐y轴要素名称,以免它们重叠.

I am plotting heatmap of features but the feature names on x and y axes conincide with each other. So how can I align x axis feature names vertically and y axis feature names horizontally so that they do not overlap.

代码:

%matplotlib notebook
corr = data.loc[:,'PERID':'PRXRETRY'].corr()

sns.set(font_scale=0.8)
sns.heatmap(corr, 
            xticklabels=corr.columns.values,
            yticklabels=corr.columns.values,cmap="YlGnBu",annot=True)

屏幕截图:

推荐答案

这对我有用:

hm = sns.heatmap(corr, cmap="YlGnBu", annot=True)
hm.set_xticklabels(labels=corr.columns.values, rotation=90)
hm.set_yticklabels(labels=corr.columns.values, rotation=0)

这篇关于如何对齐Seaborn中的xlabel和ylabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 09:08