ipython pylab figures not inline

I've installed iPython + SciPy Superpack on a Mac (OSX Lion).

If I plot using matplotlib.pyplot, it will pop up a window with the graph, and I close this for the ipython kernel to continue.

from matplotlib import pyplot as plt
plt.plot([1, 2, 3], [3, 6, 9])
plt.show()

However, If I try the inline (starting with --pylab inline or --pylab=inline ) and import pylab, instead of a plot inside the notebook (which I expect), I get an external window, which never renders anything.

Still in an external window:

import pylab
pylab.plot([1, 2, 3], [3, 6, 9])
pylab.show()

Since I've started the notebook with ipython notebook --pylab=inline it should already be so, but if I use %pylab inline in a cell and run it, I get the help, and the same code above creates a blank window, and hangs the kernel - I can only force kill the window. How should this work?


Okay - the problem was that the original ipython notebook process was still running (I'd not killed it) and the new one with the inline flag was running on a different port.

If you are having this issue - first save all your notebooks, then check you haven't got other processes running and kill any that shouldn't be running.

If you want to avoid this confusion, you can set NotebookApp.port_retries=0 in your configuration, in which case later notebook calls will give up, rather than listen on a new port. (Credit to minrk, in comments)

链接地址: http://www.djcxy.com/p/67498.html

上一篇: 是或否?

下一篇: ipython pylab数字不内联