我正在使用Matplotlib和MPLD3创建图形,可以在html页面中显示(使用django)。目前,我的图形是从csv文件中获取的数据动态生成的。偶尔在终端里会收到以下警告信息:
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 rcParamfigure.max_num_figures
). max_open_warning, RuntimeWarning)
我不太确定这意味着什么,但我假设这意味着我应该有一种关闭未使用图形的方法。有没有办法做到这一点,或者我完全错了? 谢谢。
plt.close(fig)
或plt.close('all')
。 - tacaswell