2017-06-02 209 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

聽起來像一個新的問題,不再符合這個問題。如果您的原始問題已得到解答,請接受此答案並重新發布爲新問題。這是一個問答網站,而不是技術支持討論網站。 –