matplotlib warning - how to change figure.max_open_warning setting?

2,674 views
Skip to first unread message

Andrew Krohn

unread,
Dec 14, 2014, 6:32:02 PM12/14/14
to qiime...@googlegroups.com
Hi Everyone,

I wrote myself a little script to help expedite some otu table processing (https://github.com/alk224/Cdiv_2d_and_stats).  Maybe it helps people, maybe not.  What it does is take input from the user and run:

1) core diversity (parallel)
2) anosim and permanova stats (parallel)
3) make 2d plots (parallel)

The output is great.  However, during the process of making 2D plots, it throws a bunch of errors (I assume dependent on # fields in mapping file) from matplotlib.  Not errors, per se, but warnings about opening so many figures.  There is a setting that can be changed to silence this obnoxious output.  I tried changing it in the script with the following line:

python -c "import matplotlib; matplotlib.rcParams['figure.max_open_warning'] = 0"

But that doesn't seem to do anything.  Can anyone who speaks better python help out with this?

Daniel McDonald

unread,
Dec 14, 2014, 6:50:37 PM12/14/14
to qiime...@googlegroups.com
Hi Andrew,

Thanks for that! 

Can you send on an example of the errors/warnings your getting?

Best,
Daniel

--

---
You received this message because you are subscribed to the Google Groups "Qiime Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qiime-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Krohn

unread,
Dec 14, 2014, 7:00:32 PM12/14/14
to qiime...@googlegroups.com
/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)

Daniel McDonald

unread,
Dec 14, 2014, 7:11:45 PM12/14/14
to qiime...@googlegroups.com
The make_2d_plots.py script likely isn't being as aggressive as it should with closing figures, but I don't expect anything negative to result.

Best,
Daniel

On Sun Dec 14 2014 at 5:00:34 PM Andrew Krohn <andrew...@gmail.com> wrote:
/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)

Andrew Krohn

unread,
Dec 14, 2014, 7:12:27 PM12/14/14
to qiime...@googlegroups.com
I had a problem with the organization of the anosim and permanova output.  I updated the git repository and these stats are now run on a single core.  Might help people who try this on a virtual machine.

Andrew Krohn

unread,
Dec 14, 2014, 8:34:54 PM12/14/14
to qiime...@googlegroups.com
Yea, it doesn't hurt anything, but it makes the output full of garbage.  Can anyone see why my python command isn't doing what I think it should?  

Daniel McDonald

unread,
Dec 14, 2014, 8:37:35 PM12/14/14
to qiime...@googlegroups.com
That command would need to be executed within make_2d_plots.py as the state is not persistent across processes.

Best,
Daniel

Andrew Krohn

unread,
Dec 14, 2014, 8:51:30 PM12/14/14
to qiime...@googlegroups.com
OK.  I was hoping for an answer that would set this globally.  I even tried modifying the rcparam file manually and rebooted and nothing persists.  Help, matplotlib is annoying and I can't do anything about it!!

Daniel McDonald

unread,
Dec 14, 2014, 9:21:05 PM12/14/14
to qiime...@googlegroups.com
matplotlib can be challenging to work with at times. You can always redirect stderr if that helps
-Daniel

Jorge Cañardo Alastuey

unread,
Dec 15, 2014, 4:15:10 AM12/15/14
to qiime...@googlegroups.com
Hi Andrew,

Do the matplotlib instructions to set a global rc parameters file work for you?

Best,
Jorge

Andrew Krohn

unread,
Dec 15, 2014, 11:29:38 AM12/15/14
to qiime...@googlegroups.com
Hi Jorge,

I have set that and rebooted and verified that it was still changed after a reboot.  I set it zero first as that is supposed to disable the warning, then to 10000 thinking that would be far more than the number of plots I every open and still the same behavior.  I checked via the python command line that I am modifying the correct file.  I posted a question to stackoverflow tagged with matplotlib in the hopes that a matplotlib person might be able to help.
Reply all
Reply to author
Forward
0 new messages