jakevdp / ipywidgets-static

[obsolete] Static Widgets for IPython Notebooks
BSD 3-Clause "New" or "Revised" License
108 stars 24 forks source link

Getting mpld3 plots to play with StaticInteractive widgets #12

Open ajasja opened 9 years ago

ajasja commented 9 years ago

Would it be possible to use StaticInteractive with mpld3 plots?

I have tried several of the most obvious things, none of which work.

Example notebook here.

jakevdp commented 9 years ago

Probably possible, but I've not had time to invest in it. I think that @danielballan has done something along these lines.

danielballan commented 9 years ago

Hi, @ajasja. I implemented something like this using IPython's widgets (as opposed to Jake's ipywidgets). The widgets of ipywidgets are static -- every plot for every possible widget setting is precomputed and stored in the notebook. Therefore, ipywidgets work in blog posts and generally in static webpages unconnected to an IPython kernel. IPython's widgets rely on a live IPython kernel; they compute output as needed, and they do not save a static representation of the output. Some static persistence is promised in version 3.0, but (last I heard) IPython may or may not ever include fully interactive widgets without a kernel.

Take a look at #220 for an example of my approach. I haven't made time to revisit it -- I'm trying to defend my thesis in the coming months! -- but I'd be happy to share more of my examples if you are interested.

danielballan commented 9 years ago

Oops: that is, jakevdp/mpld3#220.

ajasja commented 9 years ago

@danielballan Yes, I appreciate the difference between the static and (dynamic) IPyhon widgets. This is exactly why I'm asking about the static case. I was hoping there was an easy way to get this working. (I thought it was just a matter of somehow correctly returning the output of mpld3, so it would be captured by the correct <div> tag.) I coded up some quick and nice UI for examining our multidimensional dataset, but I'm having trouble to send this to my advisor and co workers. (I would have to host an Ipython kernel, with all the sandboxing and security precautions...) If mpld3 worked with static interactive widgets, this rather large problem goes away.

For now I just changed to matplotlibs default inline rendering (and made the plots a bit larger), which works with static widgets. This is much better than nothing, but having mpld3 with tooltips and zooming would be really impressive. But since I have a thesis to defend as well (in the next 3-6 months) I also can't devote much time to non thesis stuff.