RuntimeWarning: More than 20 figures have been opened.

Posted ZSYL

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RuntimeWarning: More than 20 figures have been opened.相关的知识,希望对你有一定的参考价值。

【Matplotlib】RuntimeWarning: More than 20 figures have been opened.

如果你创建了太多的 figure 对象,你会收到这个警告。

使用以下代码,能清除并且关闭掉 figure 对象:

plt.cla()
plt.close("all")

但是请注意,如果你需要画很多图,这样频繁的 “创建→清除” 是会拖慢你的代码运行速度的。

最好的办法是:只创建一个 figure 对象,在画下一个图之前,使用 plt.clf() 清理掉 axes,这样可以复用 figure

更多请参考:【Matplotlib】清理axes 和 figure(plt.cla、plt.clf、plt.close)

内容来源link

以上是关于RuntimeWarning: More than 20 figures have been opened.的主要内容,如果未能解决你的问题,请参考以下文章

#Leetcode# 596. Classes More Than 5 Students

leetcode 181. Employees Earning More Than Their Managers

#Leetcode# 181. Employees Earning More Than Their Managers

There's more to life than being happy

There's more to life than being happy

There's more to life than being happy