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
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 1,009 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 3,636 Feb-28-2021, 06:20 PM
Last Post: Larz60+
  Color Formatting for Bar Graphs in a for loop adamszymanski 1 948 Jan-31-2021, 01:06 PM
Last Post: jefsummers
  How to merge strings through graphs Den 6 1,536 Jun-29-2020, 07:07 AM
Last Post: Den
  Python v MatLab for graphs and plots CynthiaMoore 4 1,419 Apr-22-2020, 02:13 PM
Last Post: CynthiaMoore
  Show graphs in matplotlib from a sql query? ScaleMan 1 901 Feb-06-2020, 05:47 PM
Last Post: ScaleMan
  Tranforming into .exe with Matplotlib (graphs) ericvrocha 0 1,695 Oct-14-2019, 06:54 PM
Last Post: ericvrocha
  Little Help With Graphs ericvrocha 5 1,498 Oct-14-2019, 12:07 PM
Last Post: buran
  Drawing graphs with matplotlib JRod 5 3,169 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