Inline matplotlib figures in the Python 2.6 interactive window?

Aug 2, 2011 at 8:37 AM

The main page screenshot "i.debug.mpi.graph2.png" seems to show an inline matplotlib histogram in the Python 2.6 Interactive window. When I try to plot I get the default Qt4Agg backend and the plots in a separate window. Is there a special matplotlib backend that needs to be somehow selected for the matplotlib figures to show up inline? I searched around a bit in the pytools source code but couldn't find anything obvious indicating how to do it...

Aug 2, 2011 at 9:01 AM
Edited Aug 2, 2011 at 9:04 AM

Replying to myself here. Could it be that the screenshot is created using some repl.send_image trickery? I managed to get something similar to the screenshot with the following snippet:

>>> import sys
>>> repl = sys.modules['visualstudio_py_repl'].BACKEND
>>> from pylab import *
>>> f=figure()
>>> x=linspace(0,10,100)
>>> plot(x,sin(x))
[<matplotlib.lines.Line2D object at 0x047CA970>]
>>> f.savefig("D:/temp/hej.png")
>>> repl.send_image("D:/temp/hej.png")

This approach could perhaps be wrapped into something hackish but quite usable... :)

Aug 3, 2011 at 3:07 AM


Hi Rickard,

You're correct, the inline image support is somewhat manual right now -- partly due to the fact that both IPython & PTVS were moving targets during the past couple of months.  IPython juuuust released and fixing this didnt make it over the bar --- full inline image support will be available in 1.1.  

good hunting :).