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
Issue warning if too many figures are open #1919
Conversation
I'm 👍 for a solution which makes it obvious to noobs what is wrong, but allows the more experienced folk to get around. Nice idea @astrofrog. |
Yes -- it's an interesting idea. I'm going to tentatively milestone this as 1.3.x (not as a blocker), because I think it would be nice to have and fairly simple to implement. It also should get lots of release candidate testing on the other hand, since it feels like something that someone might have a legit problem with, though I'm not creative enough to guess exactly what. |
@@ -666,6 +666,7 @@ def __call__(self, s): | |||
'figure.edgecolor': ['w', validate_color], # edgecolor; white | |||
'figure.frameon': [True, validate_bool], | |||
'figure.autolayout': [False, validate_bool], | |||
'figure.max_num_figures': [20, validate_int], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this "figure.max_open_warning" to show explicitly that it is a warning threshold, not a hard limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding a validate_int_gt_0
validator - then you don't need to check it is positive in pyplot...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrap that. I remember now that a negative number is important... 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efiring: Yes, good suggestion on including warning
in the name.
Issue warning if too many figures are open
Good Add! I just ran into this and having the warning made it clear how to avoid the memory explosion! 👍 |
Users often ask me why they are running out of memory when plotting in loops, and this is because they are not calling
plt.close
when usingpyplot
. I wonder whether it might make sense to emit a warning above say 20 plots saying that the number of open figures has now exceeded 20, and that the user may want to close some to avoid running out of memory. I just made up the value of 20, but I was trying to think above what value it's unlikely the user deliberately has this many figures open. This could be an RC parameter so that users who do want to open 1000 figures (and have the RAM for it) can.