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
MatPlotLib Figure Freezing on Windows #2134
Comments
HI all, I'm debugging with @dmikkili . I've found that a short example script that duplicates this issue on his machine is this: from matplotlib import pyplot as plt
import time
plt.ion()
fig = plt.figure()
axis = fig.add_subplot(111)
for i in range(30000):
axis.plot(i,i,'o')
plt.draw()
if i > 5:
time.sleep(2) ## On Windows, a pause is needed to be able to click the figure at all
plt.close() This replicates the same mpl calls that we make in the much longer script where the issue occurs. I do not have any problems moving around the figure produced by this script as it changes on Mac OS X 10.6, Python 2.7, mpl 1.2.1. |
@cgohlke Can you reproduce this? |
I can reproduce this with matplotlib-1.3.0rc4. |
Which backend are you using, and does trying an alternative make any difference? |
My default backend is "MacOSX" (and I do not get the error). |
Some data points. On Linux, TkAgg works, GtkAgg stops responding (but continues to update), Qt4Agg never displays at all, and WxAgg (being Gtk under the hood) stops responding (but continues to update). |
Do we know which backend on Windows is failing, though? |
On Windows, all GUI backends are failing: TkAgg, WxAgg, GTKAgg, Qt4Agg. Qt4Agg does not display anything, the others are unresponsive. |
Hi all, I'm still having this issue. Are you guys? @dmikkili |
Yes I am still having this error. I am using WxAgg by the way. Is there a solution/workaround for this issue? |
This is not a mode of operation that we have ever supported; on some backends, on some platforms (Mike noted TkAgg on Linux) one can get away with it, but this is an accident, not something designed into mpl. Interactive mode is designed to work with ipython. That's all. The longstanding decision to delegate this to ipython could be revisited, but I suspect that no matter what we do, there will be problems with some environments. The documentation, http://matplotlib.org/users/shell.html, might need some more work to clarify the situation. Part of the problem might be the distinction between working interactively from a shell, and having a script that updates a plot based on calculations. Here is a modification of the example script above that I think will work with any interactive backend. Note that "ion()" is not needed--it is irrelevant here. import matplotlib
matplotlib.use("qt4agg")
from matplotlib import pyplot as plt
fig = plt.figure()
axis = fig.add_subplot(111)
for i in range(30000):
axis.plot(i,i,'o')
if i > 5:
plt.pause(1)
plt.close() This probably is not what you really want, though; I suspect you want long-running calculations combined with nicely-behaved interactive plots. The problem is that the window will not be responding to events (e.g., resize) during those calculations, unless you do them in a separate process, or a separate thread, or unless you sprinkle Generally, the pyplot interface is not suitable for this sort of thing; it is better to drop down to the object-oriented layer. |
I tried the modified script you wrote with the WXAgg backend, and it worked like a charm. You are right though, we did want to do if for long running calculations, and when i implemented it like the example above it was still freezing. I did however manage to get it to not freeze by just adding |
@efiring: So, at the end of the day, should we close this issue? I think reorganizing it to not rely so much on IPython is worthy of a MEP in and of itself. (I could make a MEP placeholder for it, so we don't lose track). |
@mdboom: I am happy to close it. As for a MEP: given all the backends and possible environments and circumstances in which they might be used, I think we should be cautious about trying to make all combinations work. A good first step would be some perhaps brief improvements in the documentation that we could point to when questions arise. A second step would be a concise single description of the problems to be solved. Then we might be able to see where progress can be made without getting ourselves lost in the GUI mess. |
@efiring Would you mind pointing me to some documentation that explains what you mean when you say "Generally, the pyplot interface is not suitable for this sort of thing; it is better to drop down to the object-oriented layer." What is the "object-oriented layer"? |
Thanks for the informative links @tacaswell , but I don't see how they helps to make sense of @efiring 's comment. |
@bmorris3 |
Another way to look at it is that the different GUI back ends are GUI So, the OO layer is a deeper layer in matplotlib that gives complete I hope that helps! |
for anyone find this link on google, (which i did) link above will help |
…ocked-up. 1:15pm. matplotlib/matplotlib#2134 Hmmm, yeah, this is it, but what do I do about it? What does dropping down to the OO layer mean? https://stackoverflow.com/questions/3441874/matplotlib-animation-either-freezes-after-a-few-frames-or-just-doesnt-work Ah, what a bother. Can't one just messages to a async event loop? Well it does not matter, let me just go through the example. 1:30pm. Ah, I am missing the `torchvision` module. Hmmm...how did I install PyTorch again. Did I run VS in administrator mode and then use the IDE or was it something else? Well, let me give that a shot first. 1:45pm. I am getting a broken pipe error. This is probably the IDE got a really old version of `torchvision`. I guess my memory of having to run as administrator and then from the shell was right. I'll have to wait a bit for 700mb to download. 2pm. The pipe is still broken. Well, nevermind. Let me move to the next tutorial. I'll eventually have to figure out what all of this is doing under the hood, but for the next few days I think just going through these tutorials step by step should be fine."
Python version: 2.7; Windows version: 7; Matplotlib version 1.2.1
I'm making an interactive plot (set with
plt.ion()
) while some other parts of my script do some calculations, and I update the plot frequently with calls toplt.draw()
. I noticed that when I click the figure window of the interactively drawn plot and try to move it around, the figure stops updating and Windows tags the process "Not Responding", but the script continues to run without a problem. If I don't click the figure window, everything is ok.I've read that some people have had this issue before on other forums and they got around the problem by using different backends, but my computer doesn't respond differently to other backends. What can I do?
The text was updated successfully, but these errors were encountered: