I am using Matplotlib and MPLD3 to create graphs that can be displayed in html plages (using django). Currently my graphs are being generated dynamically from data being pulled from csv files. Every so often I get this message in my Terminal:
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 rcParamfigure.max_num_figures
). max_open_warning, RuntimeWarning)
I am not really sure what it means, but I am assuming it means I should have some way of closing graphs that are not in use. Is there anyway to do this or am I completely off base? Thanks.
To avoid overlapping of labels and autopct in a matplotlib pie chart, we can follow label as a legend, using legend() method.
New! Save questions or answers and organize your favorite content. Learn more.
I preferred the answer of tacaswell in the comments, but had to search for it.
Clean up your plots after you are done with them:
plt.close(fig)
or
plt.close('all')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With