Home > Mobile >  Closing figures from previous sessions
Closing figures from previous sessions

Time:02-12

I am running a python code that produces some figures with Matplotlib and Pandas. After a few runs of the code, I am getting to following error:

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)

I think this is because I forgot to close the figures after each run of the code. I have tried

plt.close('all')

but it does not close the figures from previous sessions. Restarting the terminal (conda) did not help either.

CodePudding user response:

You have a really similar issue with really good and detailed answers in this thread.

I can tell you that you are probably creating figures in a loop or over and over with more than one execution, so you need to use the methods .clf and .cla to close the figures you are creating. But, you have all the detailed info in the above thread.

  • Related