Interactive matplotlib backend for notebook#4077
Interactive matplotlib backend for notebook#4077andreabedini wants to merge 1 commit intoipython:masterfrom
Conversation
|
We've implemented communication patterns like this (sage interacts) by registering a handler for a new custom message type. If you went that route, you wouldn't have to start a new server on a new port. Instead, you could pass messages back and forth on the existing iopub channel, right? Presumably the IPython json<->backend message spec they are working on will make this even easier. |
|
By the way, I think this is really cool and I've been looking forward to this since before Michael posted his demo. Thanks for working on it! We hope to integrate something like it into Sage as well. |
|
Thanks for the feedback. I am aware this might be an under-engineered solution but it was too easy not to have a try. Using the existing iopub channel would make much more sense indeed (think of multi-user sessions). The advantage of this solution is that it requires IPython to do nothing it already does. This so true that this PR is actually silly: everything can be implemented as an external module or extension and there's no need to merge. Can you give me a link to the custom message type implementation? |
|
@mdboom had implemented the same thing in matplotlib/matplotlib#2054 |
|
We use a bit of customization on kernel managers and the like to implement custom messages. We've had discussions with IPython devs, but never had a consensus about a plan for user-defined messages. Our registering function is at https://github.com/sagemath/sagecell/blob/master/receiver.py#L251, and our interact registration is at https://github.com/sagemath/sagecell/blob/master/interact_sagecell.py#L248. I don't know how much help it will be---we've slowly diverged with a lot of customizations from the IPython notebook kernel code. |
|
@andreabedini if this is implemented in matplotlib, why should it be duplicated in IPython? |
|
I didn't know it was. Nevertheless I don't see why it should be implemented in matplotlib. It is IPython-specific behaviour and should be implemented there, just like |
|
Thanks for doing this. We plan to provide an embeddable html canvas widget in matplotlib for a number of reasons -- it's just incomplete work at this point. There are other webapps already that want to embed it, so I think it makes sense for it to be in matplotlib and not in IPython (so that it can support things were IPython is not part of the equation). [I'm on vacation, so can't look at this in detail now, but it would be useful to compare notes between this and matplotlib/matplotlib#2054] |
|
I think this should not go in until we work out the new JavaScript message On Wed, Aug 21, 2013 at 7:16 AM, Michael Droettboom <
Brian E. Granger |
|
Also, I think as much of this should be in matplotlib as possible. On Wed, Aug 21, 2013 at 10:17 AM, Brian Granger ellisonbg@gmail.com wrote:
Brian E. Granger |
|
@ellisonbg is the new javascript message spec the one developed in IPEP 8 (and links, I guess)? It's hard to understand what's going on where. @mdboom I started from your code and simplified it, so I can provide a detailed comparison, enjoy your vacation in the meantime! |
|
No, it is different. We need to catch up on writing things down - but this https://hackpad.com/IPython-Interactive-JavaScript-Widget-Design-jRD6dHFt5I8 On Wed, Aug 21, 2013 at 3:26 PM, Andrea Bedini notifications@github.comwrote:
Brian E. Granger |
|
@andreabedini: However this ends up at the end of the day, this work is very helpful, and I especially appreciate the notes you left over at On first glance, while I think some of the IPython-specific stuff may ultimately live in IPython, there is too much code here that is copied and pasted from matplotlib that should instead be reused. ( |
|
@mdboom Cheers. It's based on the master branch. You are completely right about the duplicate code: it was needed simply because mpl lacks a suitable interface. If an embeddable widget is what we are after I think it's quite possible to work on it straight away, I'll comment on matplotlib/matplotlib#2054. |
|
We have a PR open that implements the start of our widget message spec: #4195 Can we close this PR though? I really do think all matplotlib stuff should be in matplotlib - even the notebook integration. |
|
I agree. It belongs in matplotlib. |
|
Future work on this will be in matplotlib, closing. |
Hi,
this is a matplotlib web backend tailored to work with ipython's notebook. The code is mostly taken from matplotlib's backend_webagg but it's been reworked, simplified and adapted to the notebook workflow.
How it works
Essentially it works this way:
to load the interactive backend just do
Then you can
%loadsomething from the gallery at http://matplotlib.org/examples/index.htmlAt this time the code works well, at least for local use.
Limits:
Let me know what you think of this.