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
Question written RK solving same equation with different graphs acbshinn 1 339 Feb-09-2024, 12:33 PM
Last Post: Gribouillis
  Graphs from Jupyter notebook to word Scott 0 835 Nov-28-2022, 06:16 AM
Last Post: Scott
  Plot several graphs on the same row Menthix 1 999 Mar-18-2022, 05:47 PM
Last Post: deanhystad
  grouped bar graphs tobiasfw 1 1,371 Feb-22-2022, 02:25 PM
Last Post: deanhystad
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,161 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,778 Feb-28-2021, 06:20 PM
Last Post: Larz60+
  Color Formatting for Bar Graphs in a for loop adamszymanski 1 2,885 Jan-31-2021, 01:06 PM
Last Post: jefsummers
  How to merge strings through graphs Den 6 3,369 Jun-29-2020, 07:07 AM
Last Post: Den
  Python v MatLab for graphs and plots CynthiaMoore 4 2,979 Apr-22-2020, 02:13 PM
Last Post: CynthiaMoore
  Show graphs in matplotlib from a sql query? ScaleMan 1 1,817 Feb-06-2020, 05:47 PM
Last Post: ScaleMan

Forum Jump:

User Panel Messages

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