如何删除matplotlib轴的一行(或多行),因为它实际上被垃圾回收并释放回内存?下面的代码似乎删除了该行,但从未释放内存(即使显式调用gc.collect()
)
from matplotlib import pyplot
import numpy
a = numpy.arange(int(1e7))
# large so you can easily see the memory footprint on the system monitor.
fig = pyplot.Figure()
ax = pyplot.add_subplot(1, 1, 1)
lines = ax.plot(a) # this uses up an additional 230 Mb of memory.
# can I get the memory back?
l = lines[0]
l.remove()
del l
del lines
# not releasing memory
ax.cla() # this does release the memory, but also wipes out all other lines.
那么,有没有一种方法可以从一个轴上删除一行,然后重新获得内存呢?This potential solution也不起作用。
https://stackoverflow.com/questions/4981815
复制相似问题