Python Forum
How to clear matplotlib graphs from memory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to clear matplotlib graphs from memory
#1
So I was running code earlier and got the following warning:

Warning (from warnings module): File "", line 558 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).

Warning (from warnings module): File "", line 665 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).

Not going to lie, I was being very careless and was still running it anyway, ignoring the warning. Now whenever I try to run the script, my python shell doesn't run the script.

So I am trying to remove the graphs from the memory to allow me to run script again.

I have tried the following and it still won't let me run the code:

1) plt.clf()
2) plt.cla()
3) f = plt.figure()
f.clear()
plt.close(f)

4) plt.close('all')

5) matplotlib.pyplot.figure().clear()
matplotlib.pyplot.close()

How can I fix this issue?

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Plot several graphs on the same row Menthix 1 1,029 Mar-18-2022, 05:47 PM
Last Post: deanhystad
  grouped bar graphs tobiasfw 1 1,396 Feb-22-2022, 02:25 PM
Last Post: deanhystad
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,210 Mar-11-2021, 10:52 AM
Last Post: buran
  Python Matplotlib: How do I save (in pdf) all the graphs I create in a loop? JaneTan 1 8,847 Feb-28-2021, 06:20 PM
Last Post: Larz60+
  How to merge strings through graphs Den 6 3,402 Jun-29-2020, 07:07 AM
Last Post: Den
  Show graphs in matplotlib from a sql query? ScaleMan 1 1,852 Feb-06-2020, 05:47 PM
Last Post: ScaleMan
  Tranforming into .exe with Matplotlib (graphs) ericvrocha 0 2,905 Oct-14-2019, 06:54 PM
Last Post: ericvrocha
  Little Help With Graphs ericvrocha 5 3,173 Oct-14-2019, 12:07 PM
Last Post: buran
  Drawing graphs with matplotlib JRod 5 4,701 Jul-31-2017, 10:00 AM
Last Post: JRod

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020