问题描述
使用 matplotlib
绘制多幅图出现如下问题 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). fig, ax = plt.subplots(figsize=(10, 10))
。
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`).
fig, ax = plt.subplots(figsize=(10, 10))
原因分析:
出现这种问题就是你同时绘制了多幅子图会占用大量内存,提醒你不需要时将其关闭文章来源:https://www.toymoban.com/news/detail-640410.html
解决方案:
在循环内,每次使用 plt.plot()
绘制结果后,使用代码将其关闭,再重新绘制新的子图文章来源地址https://www.toymoban.com/news/detail-640410.html
plt.close()
到了这里,关于RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!