Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Doc]: figure.show works beyond what is documented #22169

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

Closed
boffi opened this issue Jan 9, 2022 · 4 comments · Fixed by #24607
Closed

[Doc]: figure.show works beyond what is documented #22169

boffi opened this issue Jan 9, 2022 · 4 comments · Fixed by #24607
Milestone

Comments

@boffi
Copy link

boffi commented Jan 9, 2022

Documentation Link

https://matplotlib.org/devdocs/api/figure_api.html?highlight=figure%20show#matplotlib.figure.Figure.show

Problem

From the linked documentation

Proper use cases for Figure.show include running this from a GUI application or an IPython shell.

If you're running a pure python shell or executing a non-GUI python script, you should use matplotlib.pyplot.show instead, which takes care of managing the event loop for you.

I have just checked, and figure.show() works ALSO in a pure python shell (here it's 3.9, in Suse Tumbleweed).

Suggested improvement

Specify that after version 3.x (??) of the interpreter the event loop is managed also by a vanilla Python REPL.

Matplotlib Version

3.5.1

@boffi boffi changed the title [Doc]: [Doc]: figure.show works beyond what is documented Jan 9, 2022
@timhoffm
Copy link
Member

This needs a closer investigation, including python versions and backends. We can only broaden the usage of figure.show() if we are absolutely sure that it works in all scenarios.

@tacaswell
Copy link
Member

Specify that after version 3.x (??) of the interpreter the event loop is managed also by a vanilla Python REPL.

It is not the version of Python, but the GUI bindings. The ones I know off the top of my head are Qt: PyQt5 / PyQt6 register PyOs_InputHook ( https://docs.python.org/3/c-api/veryhigh.html#c.PyOS_InputHook) but pyside2/pyside6 does not. However, In the PyQt case there as also API to remove the input hook. I think tk also sets up the inputhook on import, not sure about gtk/wx/macsox off the top of my head. See https://matplotlib.org/stable/users/explain/interactive_guide.html#input-hook-integration for more details.

I suspect the re-wording should be something like "this will put the window on the screen, but you are on your own to ensure an event loop is running for the Figure to be responsive (or ever render). Use at your own risk
https://matplotlib.org/stable/users/explain/interactive_guide.html" ?

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Dec 3, 2022
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Dec 4, 2022
@QuLogic QuLogic added this to the v3.6.3 milestone Dec 13, 2022
melissawm pushed a commit to melissawm/matplotlib that referenced this issue Dec 19, 2022
@MdUmar-tech
Copy link

@boffi , Hi I have some doubt, can I get your mail id

@QuLogic
Copy link
Member

QuLogic commented Dec 12, 2023

@MdUmar-tech I'm not sure why asking a random user for their email would be helpful. If you have Matplotlib usage questions, please post them on https://discourse.matplotlib.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants