-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cleanup Matplotlib API docs #11451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup Matplotlib API docs #11451
Conversation
I think agree with those changes. One thing I have thought about is that I think that it should be clearer that pyplot include functions for starting ploting (it was clear in the new version) and functions that works on several figures or more general that do not exist somewhere else, |
|
Hm, apparently I cannot link to the documentation in api/_as_gen (I.e. stuff generated by autosummary via gallery). Then, I’d still need a second function list for pyplot - not cool. Or, alternatively I‘d have to remove or replace the pyplot top level menu entry altogether. As written above, the pyplot menu entry is debatable, but I had originally planned to discuss that later. |
Do you do the pyplot autosummary somewhere in the documentation now? |
If I understand this correctly, the pyplot autosummary is created by sphinx gallery. |
I might misunderstand the issue but I put the link in the toolbar with the master version of everything else and it did work (I first deleted all pyplot files in I don't understand all details with |
c336c6b
to
3f8a0c2
Compare
I don't completely understand the mechanism either. I did some adaption so that it now works at least. See Summary above. |
I find the "Pyplot function overview" page rather chaotic. What is the difference to the pyplot module docs, what is On the same page there is a "Colors in Matplotlib" section. What's the relation of "colors" to "pyplot"? Why have that on the same page having nothing to do with pyplot, but being in itself quite informative? I guess this should get its own page and toc link somewhere? In total why does this |
doc/api/api_overview.rst
Outdated
- Most of the :ref:`examples<api_examples>` use the object-oriented approach. | ||
|
||
|
||
The pylab API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we stopped documenting the pylab API on purpose, with the hope that "if it's not documented, it doesn't exist" (which clearly doesn't work in the case of pylab :( ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to clearly say: "pylab exists for backward compatibility, but don't use it" than to not mention pylab at all in the docs. Since there are so people who use(d) it and so many examples out there, not mentioning pylab is rather confusing than helpful.
I can make the wording stronger. Is pylab officially deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define "officially deprecated" :)
matplotlib.pylab doesn't and has never raised a deprecation warning, but I've heard for years now that it was deprecated. It was added in conjecture of the ipython --pylab
option that is also something I heard was deprecated (@Carreau may be able to confirm), but doesn't raise a deprecation warning on the version of ipython I have.
The examples were supposed to be moving away from the pylab interface and to the Object-Oriented one, but I don't believe anyone has been actively working on this aspect of documentation recently.
This is all very vague, and should probably not be considered into the review unless someone else confirms my memories of us intentionally not documenting pylab anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"officially deprecated" means there is a public statement, that this API should not be used anymore. 😄. Must not necessarily raise a deprecation warning, but the information must be publically available.
Don't know if that already exists (not found anything in the docs 😛), but I'm all in for it. I've added a deprecation mark and turned the note into a more scary looking warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples were supposed to be moving away from the pylab interface and to the Object-Oriented one
This is different from deprecating / recommending against pylab. I think pylab is really recommended against. But there should not be any pylab examples in the docs any more (If you find one, please notify, I'm happy to change that.)
pyplot on the other hand is not recommended against at all. There are reasons to use it (mostly simplicity) and the aim should probably be to make people aware of some of its shortcomings, but not remove it from the docs at all.
@ImportanceOfBeingErnest Your're with the "Pyplot function overview" page. It rather collects the weird stuff from https://matplotlib.org/api/pyplot_summary.html and https://matplotlib.org/api/index.html (see the pyplot reference at the bottom of the page). I didn't manage to get these resolved so far. Somehow we need this pyplot autosummary - otherwise the real pyplot function list is not created. I've now just put in a less public place - only accessible via "The Matplotlib API" -> "Modules" -> "Pyplot function overview". The more accessible places now link to the new "API overview" which in turn links to relevant function lists of pyplot and Figure and Axes. You are right, that this "Pyplot function overview" page has to go at some point. However, we need to find a way for the autosummary and a place to put the color docs (possibly rewrite). It's a bit of work to be done there, which I would like to defer to other PRs. To me, this PR is making things a little less awkward, or at least less obviously awkward. As such it's an improvement and may go in as is. Further improvements should go into additional PRs. |
Yes, I'm all in for the changes. One drawback I see is that the individual modules have been moved one click further away from the homepage. It might be even more difficult to find let's say the |
I agree, that it's suboptimal to have this one level deeper. OTOH to be honest, I wouldn't go through the structure anyway but use the module index or the search instead. And the previous solution of having module names right next to "Toolkits", "API changes" and "Colors in Matplotlib" is structurally worse than the proposed change. |
Yes, the proposed change is definitely for the better. In general I think the current documentation (and its structure) are very good for people who already have a little experience with matplotlib and know what to look out for. |
@NelleV, yes the --pylab and %pylab are frowned upon and all the
documentation about it have been removed. The reason in IPython is it
imports a bunch of things in the interactive namespace (from numpy import
*, from matplotlib.pylab import *) and also set the event loop integration
(which can be set separately via the gui=option). We still have a couple of
active users (fperez and gaelvaroquaux) so still keeping it around.
…On Fri, Jun 22, 2018, 03:45 Elan Ernest ***@***.***> wrote:
Yes, the proposed change is definitely for the better.
In general I think the current documentation (and its structure) are very
good for people who already have a little experience with matplotlib and
know what to look out for.
For newcomers (new to scientific python or maybe just new to matplotlib)
the documentation is not very easy to walk through.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11451 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUez3vhK5v8555SNys85YINwwMJdC3aks5t_ExNgaJpZM4Uq6hQ>
.
|
I would suggest to make a standard Set the color section in its own colors_api.rst file. I think that the list that is the result of the I would also suggest to have the I believe that this structure is possible to achieve but I don't understand all details with automodule and autosummary. One problem might be that I believe that you need to list all functions by hand in the standard auto-summary structure but that you don't need that if you use :autofunction: but that function make a link to a new page that is probably not that good. The whole API list is not that consistent. The animation_api.rst is for example more a tutorial than a api reference. |
@fredrik-1 totally agree, but can we make one step at a time? We won't get all this sorted out quickly. And I would like to get at least the partial improvement I've done here into 3.0. |
if only we knew some some people who knew @fperez and @GaelVaroquaux to talk to them .... 😈 But seriously, we can never deprecate pylab (there is the hope it eventually bit rots, no one notices and then 3 versions later we drop it but given that it is mostly import statements that seems unlikely) because it was too widely used (because it was widely advocated for a time). I would rather just not talk about pylab in the docs at all (that was the consensus we came to the last time this came up). Saying "Please don't do X" still tells a new user "You can do X". No one believes you when you say "this looks like it makes your life easier now, but will make it harder later" (that is assume they read /listen past the 'but'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to not mention pylab at all, but am willing to be over ruled.
Overall 👍
We still have a couple of active users (fperez and gaelvaroquaux) so still keeping it around
if only we knew some some people who knew @fperez and @GaelVaroquaux to talk to them .... 😈
Hahaha. "Hey, I know a place where there are still dinosaurs".
But seriously, we can never deprecate pylab (there is the hope it eventually bit rots, no one notices and then 3 versions later we drop it but given that it is mostly import statements that seems unlikely)
So, I have stopped using the imports in a long long time. Killing the
pylab namespace wouldn't break anything for me.
I still use "ipython -pylab" which is wrong by many standards (it should
be "--pylab", but it should rather be "--matplotlib"). I've been trying
to cure myself lately.
I do see the use in ipython for a shorthand for the import, but it's not
really crucial. I wouldn't advocate for keeping the pylab namespace.
|
There is one evil plan which is to |
@tacaswell In particular because pylab was/is widely used we should have a clear statement not to use it. Being silent about it rather leaves current users in the dark. Users will get pylab codes snippets somewhere. If pylab does still work and is not found in the docs, it will just be seen as incomplete documentation. IMHO the API overview is the right place for this. All other occurences in the docs should be eliminated. I'm happy to change the wording to to whatever it takes to get the message across, e.g.
|
How about officially deprecating pylab in the code? It doesn't mean that we'll remove it any time soon (/ever), but that's a clear indication to users who are still using it that they should not and means we don't have to document pylab anymore. |
We got ourselves into trouble with 'deprecated but no removal date set' not being well documented, then By officially deprecating do you mean issue warning on import of the module? There is no actual code in pylab (it is a very long docstring and then imports). If you know what you are doing (and don't expect One significant down side of the "just don't talk about it" approach is that to document that we are not going to talk about it, you have to talk about it.... This is a very long winded way of saying that @timhoffm has convinced me that we need at least a paragraph about it. Some what related, do we know who controls the scipy wiki as ( scipy.github.io/old-wiki/pages/PyLab ) is the first hit if you google for 'pylab' which is less than great... |
I'm not suggesting removing code were the deprecation date has not been set (we had the problem with the finance module as well, which had been deprecated in the documentation, but not in the code, and someone tried to remove it without the proper deprecation cycle in the code). I was suggesting deprecating it officially in the code, without a deprecation date, and not removing it until at least the very long future and with at least two releases with the version number on which it would be removed. It also gives a clear message that we will not maintain tests, do bug fixes, or write documentation about this module. (We currently have comments such as "more cleanup is needed" in the pylab.py file that suggests we might put in more work into this). |
The discussion on technical deprecation is a bit too much in the context of this PR. This is a bit of a special case of API, that we do not want people to use but possibly also do not want to take away from existing users. I'm fine with not formally depreacting pylab as of now as a coutsy to long-time users. I've reworded the pylab paragraph a bit to make it absolutely clear that it should not be used. On the other hand, I don't use the term "deprecation" anymore because for now, I explicitly do not want to make a statement if this will be removed some time in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK w/ this. A big red box can't be more clear that pylab is not the best way to do things....
@tacaswell still want pylab gone, or can this go in? You have a big red X |
Its use was removed in matplotlib#11451.
Its use was removed in matplotlib#11451.
PR Summary
This PR cleans up some parts of the Matplotlib API documentation structure. Links in the following refer to the existing documentation. Links to the changes will be added once the documentation is built.
Renamedpyplot_summary.rst
toapi_overview.rst
because that's what it actually contains. Additionally rewrote parts of the descriptions to be more to the point.Note: The "Colors in Matplotlib" section is still in here. It should be moved somewhere else - something like a concepts section (which I don't think exists in that form currently). For now, I'll still leave it here. Can be worked on in a separate PR.
Switched the link of the top-levelpyplot
menu entry to link to https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html This contains essentially the same information as the formerpyplot_summary.rst
, including the list of functions.Note: Not sure if it's reasonable to have a pyplot entry in the top level menu, but I'll leave that for now. May be worked on in a separate PR.
Edit:
api_overview.rst
and moved the relevant parts ofpyplot_summary.rst
there.Replaced the
pyplot
link in the main menu byAPI
, linking to the above API overview.