Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Matplotlib warning about too many figures #2017
There are apparently some issues in matplotlib with resource leaks in figures, which (apparently) are not always reference counted and garbage collected. Newer versions of matplotlib generate warnings when more than 20 figures are created.
This is a (minor) issue for me as I often generate large pdf files containing 100's of plots. I don't suppose there is a real figure resource limitation when writing to pdf, but I still get the warnings (I've never had any actual bad things happen, just warnings).
For statsmodels, we have the create_mpl_ax function that creates a new figure (if needed) using pyplot.figure. Supposedly if matplotlib.figure.Figure is called directly (bypassing pyplot), the reference counting and garbage collection work as expected:
There is a lot of discussion about this topic on the matplotlib lists, and I haven't spent enough time to really understand it. It's not a major issue at this point but worth exploring eventually.
I think we always call close at the end of a unit test, so there shouldn't remain any figures open that are not garbage collected, AFAIU.
For our plot funtions: Users have the choice to use the
From this, I don't see anything that we could/should do. Unless I'm missing something.
I should look into it more before speculating too much, but based on what
On Sat, Sep 27, 2014 at 4:33 PM, Josef Perktold email@example.com
I'm not sure how we can do this for the users backend
in a plain interpreter session (spyder) with QTAgg backend:
From Joe KIngton's answer it looks like we need the backend specific
And then I don't know how to actually
It still looks to me this is a case for using the
I checked that our plots that create a figure with several ax take a user given
So the main thing to make this easier, would be to add a utility function that creates a