
色んなパターンでグラフを作ってループ処理していた時のこと
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`).
plt.savefig()などでループしていても、メモリ上には過去に作成したグラフが残り続けている
必要な処理が終われば明示的にfigを閉じていけばOK
plt.close()
これでもう怒られない
参考
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.close.html

コメント