2016-06-11 5 views
1

matplotlib에서 축 레이블을 이동하려고합니다. 나는이 일 것이라고 생각하지만 그렇지 않습니다 :matplotlib에서 축 텍스트 이동

import matplotlib.pyplot as plt 
plt.figure(0) 
xlbl = plt.xlabel("foo") 
pos = xlbl.get_position() 
pos = (pos[0], pos[1] + 1) 
xlbl.set_position(pos) 
plt.draw() 

을하지만,이 작업 (Y 반대로 X 이동) 않습니다

xlbl = plt.xlabel("foo") 
pos = xlbl.get_position() 
pos = (pos[0]+1, pos[1]) 
xlbl.set_position(pos) 
plt.draw() 

나는 모든 곳에서 검색 한 및 단지를 찾을 수 있습니다 rcParams와 관련된 솔루션. 이는 그래프의 모든 레이블에 영향을주기 때문에 바람직하지 않은 솔루션입니다. 레이블 하나만 옮기고 싶습니다.

감사합니다. set_label_coords를 사용하는

답변

1

시도 : xlbl.get_position에 의해 반환되는 것들() (나는 생각한다, 상대 축이 될 것으로 보인다 좌표로 소요

import matplotlib.pyplot as plt 
plt.figure(0) 
xlbl = plt.xlabel("foo") 
pos = xlbl.get_position() 
pos = (pos[0]+0.3, pos[1]+0.5) 
ax = plt.gca() 
ax.xaxis.set_label_coords(pos[0], pos[1]) 
plt.draw() 
plt.show() 

enter image description here

+0

위치는 동일하지 않습니다 .. .). 그러나 조정에 의해 나는 그것이 작동하게했다, 고마워한다! – julienl

관련 문제