2013-02-22 3 views

답변

8
help(function) 

트릭을해야합니다.

데모 : ipython에서

def func(): 
    """ 
    I am a function who doesn't do anything, 
    I just sit in your namespace and crowd it up. 
    If you call me expecting anything 
    I'll just return to you the singleton None 
    """ 
    pass 

help(func) 
+0

그래서 plplot을 plt로 가져옵니다. 내 플롯의 위치를 ​​조정하고 싶습니다. help (pl.set_position) 또는 help (set_position)을 입력하면 오류 메시지가 나타납니다. – lord12

+0

@ lord12 - 왜냐하면'plt.set_position'이 존재하지 않기 때문입니다 ... 처음부터 함수를 어디에서 찾을 지 알아야합니다. – mgilson

+1

문서 문자열의 마지막 줄을 더 잘 작성하는 방법에 대한 제안 수락 --- http://www.youtube.com/watch?v=XaWU1CmrJNc – mgilson

2

의 supereasy - 단지 문제의 함수 (소스 코드와 함께 확장 된 정보를 원하시면 또는 ??) ?를 추가합니다. matplotlib에서 대화식으로 작업 할 때

난 항상 그것을 사용 :

In [2]: from matplotlib.axes import Axes 

In [3]: Axes.set_position?? 
Type:  instancemethod 
String Form:<unbound method Axes.set_position> 
File:  /home/tzelleke/.local/modules/active_python_2.7/lib/python2.7/site-packages/matplotlib/axes.py 
Definition: Axes.set_position(self, pos, which='both') 
Source: 
    def set_position(self, pos, which='both'): 
     """ 
     Set the axes position with:: 

      pos = [left, bottom, width, height] 

     in relative 0,1 coords, or *pos* can be a 
     :class:`~matplotlib.transforms.Bbox` 

     There are two position variables: one which is ultimately 
     used, but which may be modified by :meth:`apply_aspect`, and a 
     second which is the starting point for :meth:`apply_aspect`. 


     Optional keyword arguments: 
      *which* 

      ========== ==================== 
      value  description 
      ========== ==================== 
      'active'  to change the first 
      'original' to change the second 
      'both'  to change both 
      ========== ==================== 

     """ 
     if not isinstance(pos, mtransforms.BboxBase): 
      pos = mtransforms.Bbox.from_bounds(*pos) 
     if which in ('both', 'active'): 
      self._position.set(pos) 
     if which in ('both', 'original'): 
      self._originalPosition.set(pos) 

In [4]: 
3

, ipython에서 실행 해보십시오 경우에 입력 할 수 있습니다

In [1]: from matplotlib import pyplot as pl 

In [2]: pl.set_position? 
Object `pl.set_position` not found. 

를 여기에서 찾아 google을 사용해야합니다 그 set_positionAxes 클래스의 메소드입니다 :

In [3]: pl.Axes.set_position? 
Type:  instancemethod 
String Form:<unbound method Axes.set_position> 
File:  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.py 
Definition: pl.Axes.set_position(self, pos, which='both') 
Docstring: 
Set the axes position with:: 

    pos = [left, bottom, width, height] 

in relative 0,1 coords, or *pos* can be a 
:class:`~matplotlib.transforms.Bbox` 

There are two position variables: one which is ultimately 
used, but which may be modified by :meth:`apply_aspect`, and a 
second which is the starting point for :meth:`apply_aspect`. 


Optional keyword arguments: 
    *which* 

    ========== ==================== 
    value  description 
    ========== ==================== 
    'active'  to change the first 
    'original' to change the second 
    'both'  to change both 
    ========== ==================== 
관련 문제