# Interact.jl: plot as widget?

**URL:** https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736
**Category:** Visualization
**Created:** [October 24, 2018, 1:46pm UTC](https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736 "2018-10-24T13:46:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)
#### Post date: [October 24, 2018, 1:46pm UTC](https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736/1 "2018-10-24T13:46:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [October 24, 2018, 2:42pm UTC](https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736/2 "2018-10-24T14:42:49Z")

</div>

What is needed for this to work with the Interact framework, is to somehow get an [Observable](https://juliagizmos.github.io/Interact.jl/latest/observables.html) 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](https://github.com/JuliaGizmos/Interact.jl/issues/38) 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](https://github.com/JuliaGizmos/WebIO.jl#executing-javascript). 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).

---

<div class="post-metadata">

### Author: ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)
#### Post date: [October 27, 2018, 1:21pm UTC](https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736/3 "2018-10-27T13:21:45Z")

</div>

thanks for the info. i ended up using [bokeh](https://bokeh.pydata.org/en/latest/) 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.

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [October 27, 2018, 2:34pm UTC](https://discourse.julialang.org/t/interact-jl-plot-as-widget/16736/4 "2018-10-27T14:34:02Z")

</div>

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