Interact.jl: plot as widget?


#1

with interact.jl one can create widgets which can then change a plot. i want to click on a plot, get the x,y coordinates of where i clicked, and then generate/modify a second plot. immerse.jl could probably do this via gtk, but i was hoping to get this working in jupyter. it doesn’t seem interact.jl can currently do this, but if i’m not wrong about this, would it be easy to modify it? thanks.


#2

What is needed for this to work with the Interact framework, is to somehow get an Observable that gets updated with the position of the mouse (in terms of plots coordinates I guess). Once you have this, you can use it to trigger all sorts of events, but I’m not sure how easy it is to get the Observable in the first place (I imagine it depends on the plotting library).

For example, Makie already has it implemented (I think) so you could just use the scene.events.mouseposition Observable (this may require Makie and AbstractPlotting on master).

For Gadfly I’m not sure, but it may be feasible. I imagine the plot is represented as SVG right? Even though this issue hasn’t received any feedback in the past 4 years, I think one can add the appropriate callback in javascript (to the event “onclick” I guess to the outer svg component), recover the position of the mouse and pass the information to WebIO. I hope the WebIO docs can help, see for example here. It’s probably a bit more complicated than this but it may be worth it to open an issue at WebIO on how this could be done (adding behavior to Gadfly plots via WebIO).


#3

thanks for the info. i ended up using bokeh as my customer wanted a python solution. would be great to get this working in julia though. will look into making Gadfly support observables when time permits.


#4

Forgot to mention: PlotlyJS ha very good integration with WebIO, so it’s definitely worth a try as well to get a Julia solution