So che in R puoi semplicemente digitare? "Nome_funzione". Come lo fai in Python? Nello specifico, sto cercando di trovare informazioni su set_position
nella libreria pyplot
.Come trovare informazioni su una funzione in python?
5
A
risposta
8
help(function)
dovrebbe fare il trucco.
Demo:
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)
2
In ipython
sua supereasy - basta aggiungere ?
(o ??
per info prolungato con il codice sorgente) per la funzione in questione.
io uso sempre che quando si lavora in modo interattivo in 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
Provate a lanciare in ipython
, nel qual caso è possibile digitare:
In [1]: from matplotlib import pyplot as pl
In [2]: pl.set_position?
Object `pl.set_position` not found.
Qui, è necessario utilizzare google per scoprire che set_position
è un metodo della classe Axes
:
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
========== ====================
Problemi correlati
- 1. Informazioni su come trovare un alunno in un video
- 2. Informazioni su Python Pickle Insecurity
- 3. Comando per trovare informazioni sulle CPU su una macchina UNIX
- 4. Informazioni su Python Terminale Unicode e Linux
- 5. Ottieni informazioni sui chiamanti di funzione in python
- 6. Dove trovare informazioni su http://www.alibaba.com api in inglese?
- 7. Ottenere informazioni sul processore in Python
- 8. Come tracciare una funzione multivariata in Python?
- 9. Trovare il massimo di una funzione
- 10. Come trovare se una funzione è rientrante
- 11. Python: come fermare una funzione?
- 12. Alias una funzione in Python
- 13. Trovare una dichiarazione di stampa in Python
- 14. Ulteriori informazioni su `({});` in C?
- 15. Come trovare un id filo in Python
- 16. stampa una funzione in Python?
- 17. Informazioni su "setf" in "defun"?
- 18. Come trovare portlet aggiunti su una particolare pagina in Liferay?
- 19. jQuery - trovare non una funzione?
- 20. Informazioni su ConfigurationManager in .NET
- 21. Come trovare da dove è stata importata una funzione in Python?
- 22. Trovare informazioni sugli operatori Scala
- 23. Come trovare il numero/nome del carattere unicode in Python?
- 24. Come trovare una cornice di lettura aperta in Python
- 25. Python: trovare un elemento in una matrice
- 26. Come trovare il tipo di una funzione in Elm repl
- 27. Informazioni sul decapaggio in Python
- 28. Informazioni su IronJS
- 29. Come mutare una lista con una funzione in python?
- 30. Come ottenere ulteriori informazioni sull'avviso flag "funzione"?
Quindi importare pyplot come plt. Voglio regolare la posizione delle mie trame. Quando digito help (pl.set_position) o help (set_position) ottengo un messaggio di errore. – lord12
@ lord12 - Questo perché 'plt.set_position' non esiste ... È necessario sapere dove trovare la funzione in primo luogo. – mgilson
Accettare le proposte per un modo migliore per scrivere l'ultima riga della docstring --- http://www.youtube.com/watch?v=XaWU1CmrJNc – mgilson