Repository navigation
Description
Description of your problem
Matplotlib documentation in the help(ctrl-i) from IPython is more complete than help(ctrl-i) from the editor. I noticed this from #5514
What steps will reproduce the problem?
- Type in to the editor:
import matplotlib.pyplot as plt
plt.plot- With the cursor on
plotpressctrl-i - See this in the help widget:
Definition : plot(*args, **kwargs)
Type : Present in matplotlib.pyplot module
No further documentation available
Not overly helpful.
What is the expected output? What do you see instead?
When I do the same in IPython I get:
Definition : plot(*args, **kwargs)
Type : Function of matplotlib.pyplot module
Plot lines and/or markers to the Axes. args is a variable length argument, allowing for multiple x, y pairs with an optional format string. For example, each of the following is legal:
plot(x, y) # plot x and y using default line style and color
plot(x, y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
If x and/or y is 2-dimensional, then the corresponding columns will be plotted.
If used with labeled data, make sure that the color spec is not included as an element in data, as otherwise the last case plot("v","r", data={"v":..., "r":...) can be interpreted as the first case which would do plot(v, r) using the default line style and color.
If not used with labeled data (i.e., without a data argument), an arbitrary number of x, y, fmt groups can be specified, as in:
a.plot(x1, y1, 'g^', x2, y2, 'g-')
Return value is a list of lines that were added.
............
plus more
Please provide any additional information below
I didn't submit this before, because I thought the docs were just not so good, but if IPython can pull better docs then maybe editor can too.
Whenever I show off spyder to people often they try help with matplotlib and the results are not alway helpful.
Versions and main components
- Spyder Version: 3.2.4
- Python Version: 3.6.3
- Qt Version: 5.6.2
- PyQt Version: 5.6
- Operating system: Ubuntu 16.04 64-bit
Dependencies
IPython >=4.0 : 6.1.0 (OK)
cython >=0.21 : 0.26.1 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
numpy >=1.7 : 1.12.1 (OK)
pandas >=0.13.1 : 0.20.3 (OK)
psutil >=0.3 : 5.4.0 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.6.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.7.4 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
rope >=0.9.4 : 0.10.5 (OK)
sphinx >=0.6.6 : 1.6.3 (OK)
sympy >=0.7.3 : 1.1.1 (OK)
Activity
ccordoba12 commentedon Oct 23, 2017
I think this is fixed in Matplotlib 2.1, because in its release notes they mention that they did a great overhaul of docstrings in that release.
@bcolsen, could you update to that version and try again? Thanks!
bcolsen commentedon Oct 23, 2017
Matplotlib 2.1 didn't help this case. I did, however, reproduce #5514 on my laptop.
I think matplotlib is using doc producing functions that are not being ran when the editor retrieves the docs (using rope? Edit: it seem to be Jedi)
bcolsen commentedon Oct 23, 2017
If it's Jedi I don't think that it can be fixed through Jedi because Jedi won't run any code.
bcolsen commentedon Oct 23, 2017
Unfortunately, it seem that the most of the
pyplotfunctions only link to the documentation of the underling function using a decorator.10 remaining items
bcolsen commentedon Mar 11, 2019
From #8915: There is no documentation at all for some Pandas functions including the
pd.read_functions.[-]Matplotlib help from IPython is more complete than help from the editor[/-][+]Documentation in the help pannel from IPython is more complete than from the editor[/+]gerazov commentedon Apr 9, 2019
👍 This would be really nice to have - I use Spyder for teaching and exams, so it's important for students to be able to access Matplotlib's help with
ctrl-i.The issue with Matplotlib is that pyplot actually comprises wrapper functions meant for interactive plotting around matplotlib’s object-oriented library, i.e.
plt.plotactually callsmatplotlib.axes.Axes.ploton the current axes. So, as expected, pressingctr-ion thematplotlib.axes.Axes.plotobject in the Editor does work and prints out the whole docstring in the Help window 😄@bcolsen I also assumed that it's a problem with the docs, and just found out by accident that
plt.plot?in IPython prints an actual docstring which led me to this thread. Doingctrl-ifrom IPython is a good workaround for now - thanks for the tip!bcolsen commentedon Apr 10, 2019
I'm often doing that myself!
The real solution to this problem would likely be making a language server for the IPython console.
We could run
ctrl-ion both the editor and the console and compare them but I can't think of a good way of comparing the results.gerazov commentedon Apr 10, 2019
Lengthwise comparison should do no? Or just search for
I guess ...
I don't know how
ctrl-iworks under the hood but it seems that what can be done is fetch the docstring from the linked function. All of thepyplotfunctions have decorators for the docstring, e.g. the source code for plot starts with:Where the
_autogen_docstringfunction is defined inpyplotas:This relies on their
doctringmodule which boils down to copying thebasefunction's docstring to thetargetfunction's one with:So, I guess if your print out
func.__doc__withctrl-iit should work? Namely if I runin IPython I get the docstring. This is probably what you already do, so I dunno where things go wrong ...
bcolsen commentedon Apr 10, 2019
One solution that might work well is to make a kernel running that imports all the usual packages as their common aliases and when the editor asks for the documentation we compare the docs on the preloaded kernel to the editor.