2017-04-22 1 views
4
내가하기 matplotlib를 사용하여 로짓 규모 축 레이블을 설정할 때 라벨 위치 오류 모양을 받고 있어요

, 여기 내 예제파이썬하기 matplotlib에 ValueError는

내가

ax.set_ylabel("Y axis"); #set y axis label (logit scale) 

를 생략하는 경우

Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 136, in _draw 
    self.figure.draw(renderer) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper 
    draw(artist, renderer, *args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/figure.py", line 1143, in draw 
    renderer, self, dsu, self.suppressComposite) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images 
    a.draw(renderer) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper 
    draw(artist, renderer, *args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2409, in draw 
    mimage._draw_list_compositing_images(renderer, self, dsu) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images 
    a.draw(renderer) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper 
    draw(artist, renderer, *args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py", line 1150, in draw 
    self.label.draw(renderer) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper 
    draw(artist, renderer, *args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/text.py", line 762, in draw 
    raise ValueError("posx and posy should be finite values") 
ValueError: posx and posy should be finite values 

는 리터의 상관하지 않는 것 같습니다 좋은 작품 abel은 축척의 앞이나 뒤에 설정됩니다. 누구든지이 문제를 해결하는 방법을 알고 있습니까?

답변

2

텍스트 레이블이 설정되는 방식에 버그가있어 로짓 스케일에 숫자가 아닌 경계 상자가 생깁니다 (this issue on GitHub 참조).

용액

ax.spines['left']._adjust_location() 

는 코드 ('left'가 축에 따라 'right', 'top', 'bottom' 의해 대체 될 수있는 하나의 관심)를 추가하는 것이다.

전체 예제 :

import matplotlib.pyplot as plt 

x = [1,2,3,4,5] 
y = [0.05,0.2,0.3,0.4,0.95] 

fig,ax = plt.subplots() 

ax.set_yscale('logit') 

ax.set_xlabel("X axis") 
ax.set_ylabel("Y axis") 
ax.spines['left']._adjust_location() 

ax.plot(x,y) 
plt.show() 

enter image description here

+0

이 작동! 매우 감사! 참조 주셔서 감사합니다 :) –