2014-11-17 5 views
1

파이썬에서 matplotlib 인 상관 매트릭스 플롯을 만들려고합니다. 그러나 나는 각 사각형의 중앙에 x와 y 틱을 만들 수 없으며 xticks가 수직이되어야합니다. 음모를 꾸미려면 약 15 가지 변수가 있어야하기 때문에 수직으로 필요합니다. 따라서 수평 방향으로 진드기를 맞추는 것은 적합하지 않습니다.matplotlib와의 상관 관계 플롯 만들기

import numpy as np 
import matplotlib.pyplot as plt 

X = np.random.randn(10,3) 
X = X.T 
R = np.corrcoef(X) 
plt.figure() 
plt.xticks([0,1,2], ["first", "second", "third"], rotation='vertical') 
plt.yticks([0,1,2], ["first", "second", "third"]) 
plt.pcolor(R) 

결과 :

enter image description here

편집 :

여기 내 시도 난 그냥 rotation='vertical'를 사용하는 것은 나를 위해 X-틱 수요를 해결할 수 있음을 알아 냈다. 각 값에 0.5를 추가해야 틱 중앙 집중화

답변

1

: 또한

plt.yticks([0.5,1.5,2.5], ["first", "second", "third"]) 
plt.xticks([0.5,1.5,2.5], ["first", "second", "third"], rotation='vertical') 

, 당신은 전체 그림의 크기는 회전 X 라벨을 고려 조정되도록 다음 추가 할 수 있습니다 :

plt.tight_layout()