2017-06-02 216 views
2

我试图旋转x轴标签,但在xticks下面的功能没有任何影响,标签相互覆盖Python的pyplot x轴旋转标签

import matplotlib.pyplot as plt 
import seaborn as sns 
    corrmat = X.corr() 
    plt.xticks(rotation=90)  
    plt.figure(figsize=(15,16))   
    ax = sns.heatmap(corrmat, vmin=0, vmax=1) 
    ax.xaxis.tick_top() 

Jumbled xaxis

使用建议的代码更改后:我得到以下,但我还是想增加热图

How to increase the size of this heatmap

回答

3

的大小看起来是与pyplot(从这个answer灵感)的方式。这个工作对我来说:

import matplotlib.pyplot as plt 
import seaborn as sns; sns.set() 
import numpy as np; np.random.seed(0) 

data = np.random.rand(10, 12) 
ax = sns.heatmap(data) 
ax.xaxis.tick_top() 
locs, labels = plt.xticks() 
plt.setp(labels, rotation=90) 
plt.show() 

很显然,我没有你的数据,因此numpy的随机数据,但在其他方面与所需的效果:

enter image description here

+0

我更新我的问题与您的代码(有一些修改)。如何增加此热图的大小? – User1

+0

听起来像一个新的问题,不再符合这个问题。如果您的原始问题已得到解答,请接受此答案并重新发布为新问题。这是一个问答网站,而不是技术支持讨论网站。 –