matplotlib摆脱max_open_warning输出 [英] matplotlib get rid of max_open_warning output

查看:121
本文介绍了matplotlib摆脱max_open_warning输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个脚本,它从 QIIME 调用函数来构建一堆图等.一切运行顺利,但matplotlib始终为它创建的每个图都抛出以下反馈(超级烦人):

I wrote a script that calls functions from QIIME to build a bunch of plots among other things. Everything runs fine to completion, but matplotlib always throws the following feedback for every plot it creates (super annoying):

/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py:412:运行时警告:已打开20多个数字.通过 pyplot 接口 (matplotlib.pyplot.figure) 创建的图会保留直到明确关闭,并且可能会消耗太多内存.(要控制此警告,请参阅rcParam figure.max_num_figures ).max_open_warning,RuntimeWarning)

/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py:412: 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_num_figures). max_open_warning, RuntimeWarning)

我发现了此页面,它似乎在解释如何解决此问题,但按照指示进行操作后,一切都没有改变:

I found this page which seems to explain how to fix this problem , but after I follow directions, nothing changes:

import matplotlib as mpl
mpl.rcParams[figure.max_open_warning'] = 0

我在直接从 python 调用 matplotlib 后进入文件查看我应该调查哪个 rcparams 文件并手动将 20 更改为 0.仍然没有变化.如果文档不正确,我也将其更改为 1000,但仍然收到相同的警告消息.

I went into the file after calling matplotlib directly from python to see which rcparams file I should be investigating and manually changed the 20 to 0. Still no change. In case the documentation was incorrect, I also changed it to 1000, and still am getting the same warning messages.

我知道这对于在功率有限的计算机上运行的人来说可能是个问题,但在我的情况下这不是问题.我如何才能使这些反馈永久消失?

I understand that this could be a problem for people running on computers with limited power, but that isn't a problem in my case. How can I make this feedback go away permanently?

推荐答案

尝试通过以下方式进行设置:

Try setting it this way:

import matplotlib as plt
plt.rcParams.update({'figure.max_open_warning': 0})

不确定确切的工作原理,但是它反映了我过去更改字体大小的方式,并且似乎为我解决了警告.

Not sure exactly why this works, but it mirrors the way I have changed the font size in the past and seems to fix the warnings for me.

这篇关于matplotlib摆脱max_open_warning输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆