Non-blocking (interactive) standalone pyplot figures

Oct 30, 2013 at 8:34 PM
Hello,

How do I get non-blocking standalone (i.e. in an extra window) figures?
I've the feeling this is a simple question, but I haven't found a solution online.

This is my code
from matplotlib import pyplot
pyplot.plot(range(10))

If I choose Interactive Mode = IPython, I get inline figures.
I like inline figures, but as long as there is no solution to make individual figures in an extra window, I'd like all figures in an extra window (for zooming, saving etc.)

Interactive Mode = IPython without pylab
from matplotlib import pyplot
pyplot.plot(range(10))
pyplot.show() # plot window is active, but interpreter blocked, as expected

This opens a window, but the window in blank and I have to kill it. This is what I would have done with IPython:
from matplotlib import pyplot
pyplot.ion()
pyplot.plot(range(10))

Interactive Mode = Standard is similar.

What am I doing wrong?
Coordinator
Oct 30, 2013 at 10:21 PM
Looking at pyplot.show() docs, they mention that you can use block=False parameter to suppress blocking.
Oct 30, 2013 at 10:53 PM
Thank you, I didn't know that. When I do pyplot.show(block=False), it doesn't block, but the plot window is still not responding and blank, I need to kill it.
My understanding of pyplot is that ion() is the right approach. I just tried in IPython: pyplot.ion() plot(range(10)) figure() plot(range(20)) and get two interactive figures.
The same hangs in PTVS
Oct 30, 2013 at 11:21 PM
I found this
http://stackoverflow.com/questions/12670101/matplotlib-ion-function-fails-to-be-interactive

from matplotlib import pyplot
pyplot.ion()
pyplot.plot(range(10))
pyplot.pause(0.001)

When I run this code, the plot appears, but the plot window is not responsive, I can't zoom, save etc.
pyplot.show(block=True) makes the window responsive and blocks.
Nov 8, 2013 at 12:12 AM
Could anyone confirm if this is a problem with my setup, or a general issue with the event loop of the matplotlib gui? I am stuck, can't use the repl without interactive plotting.
Coordinator
Nov 8, 2013 at 7:26 PM
This is a general issue with the event loops. Our repl (which has its own event loop, from Visual Studio) doesn't play well with a second event loop for the plot. Since we don't control either of these, there isn't a lot we can do.

What we probably need to do is create a GUI backend for matplotlib that's going to work within VS. Unfortunately, that's something we haven't had time to look into yet, so for now inline graphs are the best we can do sorry. (Though we do welcome contributions, so if this is something you can figure out, we can certainly get it into the product. Though it may need to be contributed to matplotlib rather than us, depending on what changes are required.)
Nov 8, 2013 at 10:26 PM
Edited Nov 8, 2013 at 10:27 PM
Thank you for the explanation, unfortunately I don't have a solution either. Maybe VS could just talk to an external IPython Qtconsole. That's how I work with Vim.
Btw, I really like the inline graphs. 90% of the time, they are the right thing. The reason I don't use them is that sometimes I need to adjust figures and keep a bunch of figures open.