-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Removed idiomatic constructs from interactive figures docs #17471
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
Conversation
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.
One minor suggestion, but these all look like good improvements
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 agree with most of the wording changes, but some of the changes make the text less accurate.
doc/users/interactive.rst
Outdated
- pyplot.show runs the GUI event loop and does not return until all of | ||
the plot windows are closed | ||
- newly created figures and changes to figures are not displayed until | ||
`.pyplot.show` is called again or `.pyplot.pause` exits |
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 updates will only happen while show
or pause
are blocking and well cease after they return. You can also get an update by calling fig.canvas.flush_events
or by manually running the event loop.
Additionally, when not in interactive mode the stale hook is turned off so mutating the figure does not trigger draw_idle
.
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 so unclear about what you're getting at here/how these suggestions translate into user facing docs.
doc/users/interactive.rst
Outdated
- whether `.pyplot.show` returns immediately or after all of the | ||
figures have been closed when given no arguments | ||
|
||
- when `.pyplot.show` exits: immediately, or after all of the figures have been closed if given no arguments |
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 that "returns" is the correct language here. Processes exit, functions return.
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 hate both and think neither is super clear, especially here where it's not super clear that pyplot.show
is being talked about in the context of it being a function.
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.
"exits" is definitely incorrect for a function. Perhaps pyplot.show()
(with parentheses) would make things clearer?
doc/users/interactive.rst
Outdated
loop in some other way. | ||
at the prompt, regardless of pyplot's "interactive mode". | ||
|
||
The figures will also be "live" if you use ``pyplot.show(block=True)``, |
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 figures will also be "live" if you use ``pyplot.show(block=True)``, | |
It any case the figures will be "live" if you use ``pyplot.show(block=True)``, |
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.
In any case,
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.
in any case is an ambigious reference 'cause it's not clear what the cases are ...
doc/users/interactive.rst
Outdated
|
||
`.pyplot.figure` | ||
* `.pyplot.figure` |
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 leave these as definition lists rather than bullet points.
doc/users/interactive.rst
Outdated
<https://github.com/matplotlib/ipympl>`__. For the figures to be | ||
"live" the GUI event loop will need to be integrated with your prompt. The | ||
simplest way is to use IPython (see :ref:`below <ipython-pylab>`). | ||
<https://github.com/matplotlib/ipympl>`__. For the figures to be interactive, |
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 use "live" here to try and disambiguate it from the several other meanings of the word "interactive".
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.
"live" needs to be defined on first usage - I try to do it a little later but I can pull it up here.
@@ -67,54 +68,46 @@ loop is properly integrated with the command line (see | |||
.. highlight:: ipython | |||
|
|||
:: | |||
|
|||
user@machine:~ $ ipython |
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 is helpful to identify that we are in an IPython session, we should not assume that our readers well recognize the prompt as IPython from the style.
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.
We say that it's IPython in the narrative, but I'm fine putting this line back in. I just don't want them getting tripped up on all the details of your particular Ipython install
doc/users/interactive.rst
Outdated
|
||
.. sourcecode:: ipython | ||
|
||
%matplotlib notebook | ||
|
||
which uses the `.backend_nbagg` backend which ships with Matplotlib. | ||
However nbagg does not work in Jupyter Lab. | ||
which uses the `.backend_nbagg` backend which is installed by Matplotlib; |
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.
which uses the `.backend_nbagg` backend which is installed by Matplotlib; | |
which uses the `.backend_nbagg` backend which part of Matplotlib; |
"is installed by" implies it is an external package that we depend on which it is a first-party backend.
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.
which part of -> from
doc/users/interactive.rst
Outdated
appropriate. Matplotlib keeps a reference to all of the open figures | ||
appropriate. | ||
|
||
Matplotlib keeps a reference to all of the open figures | ||
created this way so they will not be garbage collected. You can close |
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.
Looking at this again, "this way" previously had (when this was one paragraph) some tie in to the 'Current Figure'/'Current Axes' textually, but it doesn't actually in code. So I think this line needs a clarification of what 'this way' is, or this paragraph needs to go before the paragraph on 'current'-ness.
doc/users/interactive.rst
Outdated
- pyplot.show will return immediately by default | ||
- newly created figures will be displayed immediately | ||
- figures will automatically redraw when elements are changed | ||
- `pyplot.show` displays the figures and immediately returns to the prompt |
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.
That assumes you're in a prompt...
Though in a script, if plt.ion()
is called, then plt.show()
immediately returns, and your script exits because nothing is running, so I guess you do end up at a prompt eventually (just not Python's).
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.
Yeah, this is my frustration w/ the plt.show() docs - they kind of assume a prompt too and it's really unclear.
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.
Not really? It just says show
won't return, and nothing about prompts.
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.
First line of the show docs:
When running in ipython with its pylab mode, display all figures and return to the ipython prompt
And the rest of the docs use the language of blocking but don't saw what's being blocked.
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.
That is no longer the first line of show()
docs.
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.
🤦
doc/users/interactive.rst
Outdated
loop in some other way. | ||
at the prompt, regardless of pyplot's "interactive mode". | ||
|
||
The figures will also be "live" if you use ``pyplot.show(block=True)``, |
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.
In any case,
doc/users/interactive.rst
Outdated
|
||
.. sourcecode:: ipython | ||
|
||
%matplotlib notebook | ||
|
||
which uses the `.backend_nbagg` backend which ships with Matplotlib. | ||
However nbagg does not work in Jupyter Lab. | ||
which uses the `.backend_nbagg` backend which is installed by Matplotlib; |
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.
which part of -> from
doc/users/interactive.rst
Outdated
|
||
:: | ||
|
||
In [5]: ln.set_color('orange') | ||
|
||
it will be reflected immediately. If you wish to disable this behavior | ||
use | ||
If you wish to disable interactive modification of the plot: |
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.
It is the automatic re-draw that is disabled, if you have a prompt you can always interactively modify it (even with out the event loop integration), the user then has to intentionally trigger re-draws or spin the event loop.
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 using interactive modification == automatic redraw, but will clarify that
Getting this sorted should not block tagging the RC. |
folks are welcome to squash merge this |
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.
Anyone can merge on green.
Co-authored-by: Thomas A Caswell <tcaswell@gmail.com> Co-authored-by: David Stansby <dstansby@gmail.com> Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Kind of a followup to #4779,