Wiem, że w R można po prostu wpisać? "Nazwa_funkcji". Jak to zrobić w python? W szczególności próbuję znaleźć informacje o set_position
w bibliotece pyplot
.Jak znaleźć informacje o funkcji w python?
5
A
Odpowiedz
8
help(function)
powinien załatwić sprawę.
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
W ipython
jego SuperEasy - wystarczy dołączyć ?
(lub ??
dla rozszerzonej informacji z kodu źródłowego) do funkcji w pytaniu.
Zawsze używam go podczas pracy interaktywnie w 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
Spróbuj uruchomić w ipython
, w którym to przypadku można wpisać:
In [1]: from matplotlib import pyplot as pl
In [2]: pl.set_position?
Object `pl.set_position` not found.
Tu trzeba użyć google aby dowiedzieć się, że set_position
jest metodą z klasy 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
========== ====================
Powiązane problemy
- 1. Jak znaleźć podłączone informacje o kliencie MQTT
- 2. Gdzie mogę znaleźć informacje o licencjonowaniu AppFabric?
- 3. Jak korzystać z funkcji sprawdzania, aby uzyskać informacje o dzwoniącym od klienta w języku Python?
- 4. Informacje o oddziałach OCaml
- 5. Jak sortować informacje o wersji
- 6. Uzyskaj informacje o strefie czasowej systemu w języku Python?
- 7. Gdzie mogę znaleźć informacje o wzorcach implementacji NOSQL?
- 8. Gdzie znaleźć informacje o kodach wiadomości WM Windows?
- 9. jak zdobyć informacje o sklepie w Magento?
- 10. Jak uzyskać informacje o systemie w PHP?
- 11. Jak ustawić informacje o DPI w obrazie?
- 12. Informacje o procesie NODEJS
- 13. Uzyskaj informacje o funkcjach dzwoniących w pythonie
- 14. Informacje o wyjątku: System.Reflection.TargetInvocationException
- 15. Noś informacje o poprzednich obliczeniach
- 16. Jak wyprowadzić informacje do konsoli w skrypcie python Gimp?
- 17. Dlaczego python wyświetla informacje o wersji na stderr?
- 18. Jak uzyskać informacje o stosie wątków w systemie Windows?
- 19. Drupal uzyskać informacje o module?
- 20. Jak uzyskać informacje o aktywności z IDialogContext
- 21. informacje o identyfikatorze procesu log4net
- 22. Jak uzyskać informacje o indeksie i właścicielu tabeli w Oracle?
- 23. Jak zapewnić informacje o kolumnie nieujemnej?
- 24. Informacje o urządzeniu z Androidem
- 25. AssemblyInfo informacje o wersji gwiazdkami
- 26. Uzyskaj informacje o sprzęcie w systemie Android?
- 27. C#: uzyskać informacje o komputerze w domenie
- 28. Informacje o rozszerzeniu pliku .MI?
- 29. maven build - informacje o wersji
- 30. Informacje o trybie androidowym "singleTask"
Więc importuję plik Pyplot jako PLT. Chcę dostosować pozycję moich działek. Kiedy wpisuję help (pl.set_position) lub help (ustawienie_pozycji), pojawia się komunikat o błędzie. – lord12
@ lord12 - To dlatego, że 'plt.set_position' nie istnieje ... Musisz przede wszystkim wiedzieć, gdzie znaleźć swoją funkcję. – mgilson
Przyjmowanie propozycji sposobu lepszego napisania ostatniego wiersza docstringu --- http://www.youtube.com/watch?v=XaWU1CmrJNc – mgilson