Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotting.py:144: RuntimeWarning: More than 20 figures have been opened. #131

Closed
ghost opened this issue May 28, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented May 28, 2020

Hi,
When I use plot to draw efficient frontier and covariance charts and set a file name to save the results, after saving some images it raises this warning.
I try to correct this by adding the line
plt.cla()
after the
plt.savefig(fname=filename, dpi=dpi)
but it does'nt work.
Also I try to close the plt but could not.

Screenshots
/lib/python3.7/site-packages/pyportfolioopt-1.2.2-py3.7.egg/pypfopt/plotting.py:144: 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_open_warning).

Thanx for your help
Best Regards
Barmak

@ghost ghost added the bug Something isn't working label May 28, 2020
@robertmartin8
Copy link
Owner

Hi Barmak,

Thanks is a common problem with matplotlib. Could you try plt.close("all")? Failing that, perhaps some of the suggestions in this SO post might help.

Best,
Robert

@ghost
Copy link
Author

ghost commented May 28, 2020

Thank you.
I try that before and it works. But in case of using with simultaneous user it may cause problem.
I want to close only the plot handle of the current session user. But It could be ignore.
Many thanks
& Regards
Barmak

@robertmartin8
Copy link
Owner

I think plt.close() just closes the latest figure, so you could run that after each generating each plot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant