-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Crash when interactively adding a number of subplots #11123
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
Comments
What happens if you turn off tight layout? What does this look like in non crashing 2.0.2? |
Hm, without tight_layout it doesn't crash in 2.2.2, but it shouldn't crash with tight_layout. How does it look? A white window, in which plots are appearing, while the plots are appearing the window is resizable and those plots are being resized with the figure. I'm using similar code for monitoring of online EEG signal. I add subplots on-line when new statistic is calculated and available. My code was crashing and I've narrowed down to this minimal example. I use tight_layout for so the plot titles and labels wouldn't overlap and screen space usage would be optimal. |
Pre-allocating is a bit safer, it seems: fig, axs = plt.subplots(10, 10, figsize=(10, 10))
for ax in axs.flat:
ax.set_visible(False)
for i, ax in enumerate(axs.flat):
ax.set_visible(True)
ax.plot([0, 1], [0, 1])
fig.tight_layout()
fig.canvas.flush_events()
print(i)
time.sleep(0.01)
if i == 25:
fig.set_size_inches(3, 3) does not crash as far as I can tell. |
Pre-allocating is safer. But when you have 3 dynamic plots using all figure space, and then you collect enough data and want to show new plot, you have to use |
This is fixed in master #10915. Trying to backport to 2.2.3... The behaviour in master is to warn when tight_layout can't make the axes small enough anymore rather than giving a ValueError |
Closed by #10915. Not sure it’s exacty what you wanted but at least it doesn’t crash. Thanks for the report. |
Bug report
Bug summary
Adding subplots repeatedly to a figure in interactive mode can sometimes crash Matplotlib version 2.2.2, in version 2.0.2 everything works. Sometimes it does not crash, but when you resize figure's window to make it significantly smaller it crashes every time. I'm using Matplotlib on Kubuntu 16.04 64 bit with Python 3.5.2.
Code for reproduction
Actual outcome
While adding 25th subplot it crashes. You can crash it earlier if you manually resize the window to make it smaller.
Expected outcome
Interactive matplotlib window with dynamically added 100 plots. While plots are being added window should be resizable. After 25'th plot it will make itself smaller in an effort to reproduce the bug. In Matplotlib version 2.0.2 it works without crashing.
Matplotlib version
print(matplotlib.get_backend())
): TkAggInstalled matplotlib using:
pip3 install --user matplotlib==2.2.2
The text was updated successfully, but these errors were encountered: