问题描述
使用 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))
原因分析:
出现这种问题就是你同时绘制了多幅子图会占用大量内存,提醒你不需要时将其关闭
解决方案:
在循环内,每次使用 plt.plot()
绘制结果后,使用代码将其关闭,再重新绘制新的子图
plt.close()
标签:20,opened,figure,pyplot,warning,through,RuntimeWarning,More
From: https://www.cnblogs.com/chentiao/p/17580213.html