I have a data analysis module that contains functions that call the Matplotlib Pyplot API several
Can you edit your functions calling matplotlib? I ran into the same problem, I tried to execute the following command, but none of this worked.
plt.close(fig) fig.clf() gc.collect() %reset_selective -f fig
Then one trick worked for me, instead of creating a new shape every time, I pass the same fig object to a function, and this solved my problem.
for example use
fig = plt.figure() for i in range(100): plt.plot(x,y)
instead
for i in range(100): fig = plt.figure() plt.plot(x,y)
source share