Closing figures in nbagg mode

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

Hi Phyks

You don't supply any information about which version of matplotlib you are
using (since you are talking about a cross in the upper right i guess you
are using 1.4.x as we changed that icon in 1.5) so this is a bit of a guess
work.

#4281 is a closed issue because this has been fixed and the fix is in
matplotlib 1.5.0 and 1.5.1. If you are running 1.4.x there is a bug that
prevents figures from being closed correctly when the cell is being rerun
and the number of figures rapidly exceeds 20 if you rerun the same cells
multiple times. In 1.5.x and forwards a figure will be correctly. If you
are using the notebook backend with matplotlib 1.4.x I strongly urge you to
upgrade.

If you really have a notebook with more than 20 individual figures you are
likely to suffer from degraded performance and should perhaps consider if
splitting the notebook into multiple makes sense.

best
Jens

···

On Tue, 1 Mar 2016 at 16:59 Phyks <spam+matplotlib at phyks.me> wrote:

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
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160302/4babf883/attachment.html>

Hi,

Sorry, I missed the infos about matplotlib version. I use the up-to-date
version (1.5.1). And indeed, it is not a cross, but a "shutdown" button,
got confused by the old version I saw on another computer.

Thanks for the infos about the state of the issue, closing the figures
in the notebook should then be fine!

Le 02/03/2016 15:12, Jens Nielsen a ?crit :

···

Hi Phyks

You don't supply any information about which version of matplotlib you are
using (since you are talking about a cross in the upper right i guess you
are using 1.4.x as we changed that icon in 1.5) so this is a bit of a guess
work.

#4281 is a closed issue because this has been fixed and the fix is in
matplotlib 1.5.0 and 1.5.1. If you are running 1.4.x there is a bug that
prevents figures from being closed correctly when the cell is being rerun
and the number of figures rapidly exceeds 20 if you rerun the same cells
multiple times. In 1.5.x and forwards a figure will be correctly. If you
are using the notebook backend with matplotlib 1.4.x I strongly urge you to
upgrade.

If you really have a notebook with more than 20 individual figures you are
likely to suffer from degraded performance and should perhaps consider if
splitting the notebook into multiple makes sense.

best
Jens

On Tue, 1 Mar 2016 at 16:59 Phyks <spam+matplotlib at phyks.me> wrote:

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
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users