matplotlib/matplotlib — pull request #2054 by mdboom (2013-05-23 14:56:42+00:00)
Title: Ipython/Webagg integration

This integrates the WebAgg backend with the IPython notebook.

It works by running its own Tornado server in its own thread in the kernel. (There doesn't seem to be any logical way to integrate mpl's tornado server with IPython's, since IPython's runs in the frontend, not the kernel). This actually seems to work quite well, despite all of the gotchas with Python threading -- remember, this is how all of matplotlib's GUI backends have worked since time immemorial ;)

Since IPython doesn't have any native understanding of WebAgg, the backend must be set in your `matplotlibrc` file, and ipython started without the `--pylab` flag. Anything else will likely give you the wrong backend. It should be straightforward for IPython to add `webagg` as an option for `pylab` (or use it instead of inline) to avoid needing to be so careful in the future.

To display figures inline, either call `plt.show()` as the last line of an input block to display its output (this will show all figures), or simply display a figure object.

As an aside change, this removes the need for putting special element ids on things so they can be found later -- this now just builds all of the DOM elements by hand and assigns them as it goes to the figure object. Much cleaner, and less risk of element id namespace clashing.

This may be too big a chunk of work to properly vet before 1.3.0, but it should be sufficient to demo and discuss with IPython folks at Scipy.