crystalmath8450
crystalmath84504mo ago

Putting draggable objects on a plotted 2D array using plotly

Hi, I've just started using plotly and want to play around with the interactivity, but I cannot find a lot of information on things like 2D plots. How can I make a draggable object (e.g. a rectangle) that the user can move around on an interactive 2D plot? I would like to e.g. sum the pixel values inside the draggable shape. Thanks in advance!
4 Replies
Akshay
Akshay4mo ago
Hey! That level of interactivity is likely not supported in Plotly. But maybe you could build something like this with an existing anywidget? cc @Jan-Hendrik Müller
Jan-Hendrik Müller
hi @crystalmath8450 !
I would like to e.g. sum the pixel values inside the draggable shape.
Yes, that would be possible to build with anywidget. I can think of a a widget based on https://konvajs.org/docs/sandbox/index.html for calculating pixel values inside the draggable shape. I think it would take me about 1-2 days to build a pixel sum widget.
crystalmath8450
crystalmath8450OP4mo ago
Hey all, thanks for the replies. I found the implementation below using Dash for this kind of interactivity: https://dash.plotly.com/interactive-graphing?_gl=1*18hn11a*_gcl_au*MTg2NzkzNTU5NS4xNzI0MDg2NDM2LjE2MjA0OTQ3ODMuMTcyNDEwNjQ1NC4xNzI0MTA2NDc0*_ga*NTkyNTg5NDEyLjE3MjQwODY0MzY.*_ga_6G7EE0JNSC*MTcyNDI0OTg3Mi42LjEuMTcyNDI1MDEyMS42MC4wLjA. But you would have to write callback functions (and again I am not very familiar with these kinds of things, so I thought marimo would have made it easier). In any case, is something like this possible with another visualisation package like Altair?
Part 3. Interactive Graphing and Crossfiltering | Dash for Python D...
Graphs can be inputs as well as outputs: bind interactivity to the Dash Graph component whenever you hover, click, or select points on your chart.
crystalmath8450
crystalmath8450OP4mo ago
I'll have a look at anywidget though! Looking more into this, actually plotly/Dash do not support the box/lasso select tool on 2D heatmaps, so this would be a bit tricky to implement that way