Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib get rid of max_open_warning output

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: 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 

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?

like image 473
Brassmonkey Avatar asked Dec 15 '14 02:12

Brassmonkey


1 Answers

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.

like image 80
robb Avatar answered Sep 23 '22 09:09

robb