Ich weiß in R können Sie einfach eingeben? "Function_name". Wie machst du das in Python? Insbesondere versuche ich Informationen über set_position
in der pyplot
Bibliothek zu finden.Wie finde ich Informationen über eine Funktion in Python?
5
A
Antwort
8
sollte den Trick tun.
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
seine Supereasy - nur anhängen ?
(oder ??
für erweiterten Informationen mit Quellcode) für die Funktion in Frage.
ich es immer verwenden, wenn interaktiv in matplotlib
arbeiten:
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
Versuchen in ipython
ausgeführt wird, in diesem Fall können Sie eingeben:
In [1]: from matplotlib import pyplot as pl
In [2]: pl.set_position?
Object `pl.set_position` not found.
Hier haben Sie google verwenden, um herauszufinden, dass set_position
eine Methode der Axes
Klasse ist:
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
========== ====================
Verwandte Themen
- 1. Wo finde ich Informationen über eine Syntax in JS-Dokumenten?
- 2. Wie finde ich Informationen zum Anrufer?
- 3. Wo finde ich Informationen über Blog-APIs und deren Verwendung?
- 4. Wo finde ich Informationen über das C++ - Attribut [[Deprecated]]
- 5. Wo finde ich umfassende Informationen zur Bildbearbeitungsbibliothek?
- 6. Wie finde ich Mime-Typ in Python
- 7. Wo finde ich Informationen zu NOSQL-Implementierungsmustern?
- 8. Wie man Informationen über eine Funktion erhält und sie aufruft
- 9. Erhalten Funktion Anrufer Informationen in Python
- 10. Wie schreibe ich eine Funktion in Python
- 11. Wie finde ich eine Instanz einer gebundenen Methode in Python?
- 12. Wie finde ich eine Datei in Python nach oben?
- 13. Wie finde ich Anführungszeichen in Strings - Python
- 14. Wie finde ich den Dateisystemtyp in Python
- 15. Wie finde ich Zeit mit Python?
- 16. Wie finde ich heraus, wo eine Python-Warnung ist von
- 17. Wie finde ich heraus, wo eine Python-Warnung ist von
- 18. Wie finde ich heraus, woher eine Funktion in Python importiert wurde?
- 19. python lxml Wie finde ich mehrere Markups?
- 20. Wie finde ich heraus, wo eine Funktion definiert ist?
- 21. Informationen über UML?
- 22. Wie finde ich die Ordner Informationen im Dokumentverzeichnis
- 23. Wie finde ich die globale Funktion?
- 24. Wie finde ich x in einer Zeichenfolge in Python
- 25. Finde heraus, ob eine Funktion hat
- 26. Wie kann ich Informationen über eine angeklickte Markierung erhalten, die nicht über das Overlay hinzugefügt wurde?
- 27. Wie finde ich ein Array-Objekt nach gegebenen Informationen?
- 28. Wie finde ich Informationen zur parallelen Architektur meiner CPU?
- 29. Wie finde ich Verwendungen einer Objective-C-Funktion in Xcode?
- 30. Wo finde ich Informationen zur Struktur des Delphi VMT?
Also importiere ich pyplot als plt. Ich möchte die Position meiner Plots anpassen. Wenn ich help (pl.set_position) oder help (set_position) eingebe, erhalte ich eine Fehlermeldung. – lord12
@ lord12 - Das liegt daran, dass 'plt.set_position' nicht existiert ... Sie müssen zuerst wissen, wo Sie Ihre Funktion finden. – mgilson
Vorschläge für eine Möglichkeit zum besseren Schreiben der letzten Zeile des Docstrings akzeptieren --- http://www.youtube.com/watch?v=XaWU1CmrJNc – mgilson