Skip to content

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

Merged
merged 6 commits into from
Jun 16, 2020

Conversation

story645
Copy link
Member

Kind of a followup to #4779,

  • stripped out some idiomatic language
  • cleaned up Jupyter capitalization
  • put the descriptions before the code in the code snippets (my docs don't build so I don't know if it renders the snippets...),
  • reworded some things to hopefully be clearer

Copy link
Member

@dstansby dstansby left a 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

Copy link
Member

@tacaswell tacaswell left a 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.

- 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
Copy link
Member

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.

Copy link
Member Author

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.

- 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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

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)``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)``,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case,

Copy link
Member Author

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 ...


`.pyplot.figure`
* `.pyplot.figure`
Copy link
Member

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.

<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,
Copy link
Member

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".

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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


.. 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of -> from

@tacaswell tacaswell added this to the v3.3.0 milestone May 21, 2020
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
Copy link
Member

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.

- 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
Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

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)``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case,


.. 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of -> from

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label May 27, 2020
@QuLogic QuLogic requested a review from tacaswell May 30, 2020 08:17

::

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:
Copy link
Member

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.

Copy link
Member Author

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

@tacaswell
Copy link
Member

Getting this sorted should not block tagging the RC.

@tacaswell tacaswell dismissed their stale review June 9, 2020 17:50

outdated

@story645
Copy link
Member Author

folks are welcome to squash merge this

Copy link
Member

@tacaswell tacaswell left a 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>
@QuLogic QuLogic merged commit f8e4012 into matplotlib:master Jun 16, 2020
@story645 story645 deleted the interactivity branch June 16, 2020 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants