1

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.

Code:

%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)

Screenshot:

enter image description here

stone rock
  • 1,923
  • 9
  • 43
  • 72
  • I guess I forgot to explicitely state *"... under the condition that it hasn't been asked before"* in [my last comment](https://stackoverflow.com/questions/49315084/how-to-resize-the-correlation-plot-for-better-visualization?noredirect=1#comment85643788_49315084). – ImportanceOfBeingErnest Mar 16 '18 at 13:11

1 Answers1

2

This works for me:

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)
sjw
  • 6,213
  • 2
  • 24
  • 39