Skip to content
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

matplotlib inline and plt.show() #126

Open
klieret opened this issue Sep 13, 2022 · 4 comments
Open

matplotlib inline and plt.show() #126

klieret opened this issue Sep 13, 2022 · 4 comments

Comments

@klieret
Copy link
Member

klieret commented Sep 13, 2022

Was also a question at pyhep: Is plt.show() really necessary?

I think we should explain what it does and also %matplotlib inline.

Might also talk about how return values are shown (sometimes leading to plots being shown double, which is why people then add ;...)

@klieret klieret added needs-discussion type:enhancement New feature or request labels Sep 13, 2022
@klieret
Copy link
Member Author

klieret commented Sep 13, 2022

The %matplotlib inline is only needed for Classic Jupyter. JupyterLab recognizes Matplotlib out of the box.

From @jpivarski

@jpivarski
Copy link

The rationale for plt.show() that Alex Briceño gave, that it prevents the Matplotlib object repr from being shown, is not a strong reason. The same would be accomplished by replacing "plt.show()" with "None". What's happening is that Jupyter is showing the repr of the last Python object returned by the last line in the cell. (plt.show() returns None.)

A better argument could be made that plt.show() is necessary when you're not in Jupyter, but then the workflow is entirely different: if it's in a single threaded Python commandline, you don't get access to do anything in Python until you close the window that plt.show() pops up. So that's not a very friendly way of working, anyway. But anyway, including the plt.show() is indicating where it would be needed if you weren't using Jupyter, in case somebody needs to know that.

@amorenobr
Copy link
Contributor

Thanks Jim for the clarification!

@stale
Copy link

stale bot commented Nov 29, 2022

This issue or pull request has been automatically marked as stale because it has not had recent activity. Please manually close it, if it is no longer relevant, or ask for help or support to help getting it unstuck. Let me bring this to the attention of @klieret @wdconinc @michmx for now.

@stale stale bot added the stale label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants