[Matplotlib-users] How to close plot window in interactive mode?

Juan Nunez-Iglesias jni at fastmail.com
Tue Jun 30 21:54:31 EDT 2020


Hi Jerzy,

On Tue, 30 Jun 2020, at 2:58 PM, Jerzy Karczmarczuk wrote:
> 
> Le 30/06/2020 à 20:30, Gilles Allard a écrit :
> > I'm searching for a way to close (programmatically) a plot window in
> > interactive mode.
> > What is the best way?
> 
> Oh, you are searching, you say... Why not (with plt meaning 
> matplotlib.pyplot):
> 
> plt.close(myFigure)
> 
> To see if it is the best or not... read the manual perhaps?... For example
> 
> https://matplotlib.org/api/_as_gen/matplotlib.pyplot.close.html
> 
> Google gives you  1 050 000 results if you type "matplotlib close window"!

1M results is a lot of noise to wade through. Additionally, it is a well-documented problem that a lot of Matplotlib answers on the web are out of date and use APIs that are no longer recommended by the core team. It is not reasonable to expect new users to be as effective at cutting through that noise as more experienced ones. Nor is it reasonable to expect everyone to have read through *all* the very extensive matplotlib documentation before daring to post to the list.

For example, if I click on your link to `plt.close`, I might reasonably follow through to the `Intro to pyplot` tutorial, which uses the Matplotlib state machine interface rather than the currently-recommended OO interface. I know that the OO interface is recommended only because I have years of experience with Matplotlib, but there is a good chance that newcomers would not have heard this recommendation.

This is exactly where the Matplotlib users list can help, but only *if* we are welcoming and encouraging to newcomers, rather than drive them to never post to the list again, or worse, away from this community altogether.

In short, if you want to "teach users to fish", that's fine, I get that. But this can be done with encouragement and direction rather than sarcasm and scorn.

Juan.


More information about the Matplotlib-users mailing list