Search code examples
pythonmatplotlibcygwin

Interactive matplotlib/ipython figures on Windows


I'm having trouble getting matplotlib up and running on a recent Win7/Cygwin installation.

I've use the Cygwin package manager to install python 2.7.8, but the mirrors I have tried don't seem to include packages for ipython or matplotlib. I've used Cygwin to install the prerequisite packages

pkg-config ghostscript libfreetype-devel libpng-devel python-gtk2.0 libgtk2.0-devel gcc-g++ git

(a list I found here) and installed both matplotlib and ipython from their git repositories:

git clone git://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install

cd ..

git clone https://github.com/ipython/ipython.git
cd ipython
python setup.py install

I can successfully plot from a standard python prompt by manually calling show(), or from an ipython session (started without --pylab) also by manually calling show(). In both cases show() blocks the terminal input until the plot window is closed, and closing the figure resets it so that subsequent plotting commands begin with a blank canvas.

If I run ipython --pylab, or run pylab.ion() from within ipython, then plotting commands bring up the canvas automatically as I'm used to on MacOS --- but the canvas never contains any visible axis, only a grey frame! In this case show() does nothing. The figure does seem to be getting built somewhere: as I add lines and curves, I can call gca().get_children() and see that more figures are being added to the axis; I can also use gcf().save_fig('foo.png') to put reasonable output to a file. But for some reason the communication with the X window is broken.

I believe that I'm using the TK backend; I'm not married to that choice, but it's not clear how I should install other backends.

I would appreciate any guidance that ends with my plotting interactively.


Solution

  • It seems to have been a transient bug due to having followed the head of the development tree. After updating this morning using

    git pull && python setup.py install
    

    in both directories, I have proper interactive behavior.