[Matplotlib-users] Closing figures in nbagg mode

Phyks spam+matplotlib at phyks.me
Tue Mar 1 11:59:23 EST 2016


Hi,

I have a jupyter notebook (using "%matplotlib notebook") which is
drawing a lot of figures using matplotlib. When I run all the cells, I
have more than 20 figures and then get the following warning:

/home/phyks/.local/share/virtualenvs/physique/lib/python3.5/site-packages/matplotlib/pyplot.py:516:
RuntimeWarning: More than 20 figures have been opened. Figures created
through the pyplot interface (`matplotlib.pyplot.figure`) are retained
until explicitly closed and may consume too much memory. (To control
this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)


I was wondering what is the correct workflow for handling it. I mean,
should I close the figures regularly, or can I just leave them open (at
the expense of memory and CPU usage)?

Moreover, I am not sure to fully understand how to close them.
https://github.com/matplotlib/matplotlib/issues/4281 tends to make me
think it is not enough to just click the top right X to close them,
contrary to what I would have thought.

Thanks!
-- 
Phyks


More information about the Matplotlib-users mailing list