首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何删除Matplotlib图中的线条

如何删除Matplotlib图中的线条
EN

Stack Overflow用户
提问于 2011-02-13 09:19:12
回答 5查看 138.2K关注 0票数 93

如何删除matplotlib轴的一行(或多行),因为它实际上被垃圾回收并释放回内存?下面的代码似乎删除了该行,但从未释放内存(即使显式调用gc.collect())

代码语言:javascript
复制
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也不起作用。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4981815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档