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

max open warning #64

Open
MerlinPendragon opened this issue Aug 9, 2018 · 5 comments
Open

max open warning #64

MerlinPendragon opened this issue Aug 9, 2018 · 5 comments

Comments

@MerlinPendragon
Copy link

MerlinPendragon commented Aug 9, 2018

Hi, I use ipympl in jupyterlab.%matplotlib widget opens a different figure for the same cell after each run. Soon I'll get this max open warning, which is kinda irritating. %matplotlib notebook has no such issue. Is there a way to not open another figure in the same cell?

image
(%matplotlib widget)

image
(%matplotlib notebook)

@flutefreak7
Copy link

I'll bump this as well because this is one of a few irritating behaviors that need to be resolved. The cleanest way I've seen of dealing with this particular issue is something like this:

plt.close('awesome plot 1')
plt.figure('awesome plot 1')

This way it always clears the previous named instance of the plot. The close command also does nothing on a first pass in which the figure is already closed. This also works with integers, though you run the risk of accidentally closing a different figure since matplotlib creates integer numbered figures by default.

The downside is obviously that you have to uniquely name your figures.

@tacaswell
Copy link
Member

plt.close('all') will also close all open figures.

I think the underlying problem here is that with nbagg when the js-widget is removed from the DOM we tear down the figure on the pyplot side and (try) to release all of the references, however with ipympl because the widget may be shown in multiple contexts.

There needs to be some reference counting to tell when there are no visible figures left?

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Jun 28, 2019

If you know you will have plenty of ram, you can increase the number of figures before there's a warning:

import matplotlib.pyplot as plt
plt.rcParams['figure.max_open_warning'] = 2000 # default is 20

@tacaswell
Copy link
Member

The reason we have the warning in people were accumulating enough open figures to OOM their python process...

@erickson33
Copy link

Hi all, just checking if there are any updates on this. I'm a daily user, and I agree with Merlin that it is pretty irritating.

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

No branches or pull requests

5 participants