2014-02-14 8 views
2

필자는 극좌표를 사용하여 일부 데이터를 나타냅니다. 현재 X 축 바로 위에 위치한 레이블을 데이터 세그먼트 위에 놓고 싶습니다. 그래서 축 사이.python matplolib 극좌표 차트 x 축 레이블 위치

모든 것을 회전하는 방법에 대한 기사가 여러 개 있지만 항상 축 바로 위의 레이블을 유지합니다.

내가 (당신이 전체 정의/코드를 필요로하는 경우, 그렇게 말하십시오) 축에 대한이 코드의 평화 :

# Set axis names and orientation 
ax.set_theta_zero_location("N") 
ax.set_xticklabels(['Seg 1', 'Seg 2', 'Seg 3', 'Seg 4', 'Seg 5', 'Seg 6', 'Seg 7', 'Seg 8']) 
ax.set_ylim((0, 10.0)) 
ax.set_rgrids([5,10], angle=22) 

현재의 이미지가 생성됩니다

enter image description here

이제 'Seg 1', 'Seg 2' 등의 레이블을 축 사이에서 축에서 오른쪽으로 이동시키고 싶습니다.

그렇게 할 방법이 있습니까?

답변

2

당신은 작은 진드기에 레이블을 설정,하지만 그래서 당신이 그들을 볼 수 없습니다 제로로 작은 눈금 폭을 설정하여이 작업을 수행 할 수 있습니다

 
import matplotlib.ticker as ticker 

# Set the major and minor tick locations 
ax.xaxis.set_major_locator(ticker.MultipleLocator(np.pi/4)) 
ax.xaxis.set_minor_locator(ticker.MultipleLocator(np.pi/8)) 

# Turn off major tick labels 
ax.xaxis.set_major_formatter(ticker.NullFormatter()) 

# Set the minor tick width to 0 so you don't see them 
for tick in ax.xaxis.get_minor_ticks(): 
    tick.tick1line.set_markersize(0) 
    tick.tick2line.set_markersize(0) 
    tick.label1.set_horizontalalignment('center') 

# Set the names of your ticks, with blank spaces for the major ticks 
ax.set_xticklabels(['','','Seg 1','','Seg 2','','Seg 3','','Seg 4','','Seg 5','','Seg 6','','Seg 7','','Seg 8'],minor=True) 
+0

감사합니다! 그것은 내 컴퓨터에서 즉시 작동했습니다. 그러나 원격 사이트에서 시도했을 때 그렇게하지 않았습니다. 오류는 없지만 라벨이 움직이지 않았습니다. matplotlib를 업데이트 한 후 매력처럼 작동했습니다. 그래서 이것은 최신 버전에서만 작동하는 것 같습니다. 아니면 이전 버전이 있습니까? –