Just starting to use plotly with Python and trying to figure out how to receive mouse events. So far all the docs I’ve seen seem to imply that the code needs to run on a Jupyter notebook.
Is there no way to receive mouse events with Python alone (I am using VSCode if this matters)? I get it that the plotting is done in a browser. Is there perhaps an alternative non-browser way to plot it that will allow mouse events to be sent back to the python code?
No, I was referring to Plotly with Python. However, if it’s impossible to achieve with Plotly alone and Dash does have this functionality, then I might need to look into Dash as well.
I am working on optimizing parameters for trading systems. I want to have the following workflow:
Optimize with various parameters (I wrote the code in python).
Plot the optimization results as a 3D surface (I write the code for this using Plotly Python)
A mouse click on any point on the surface should be received back to the python code, in which I will have a function to do some further processing on the specific parameters chosen.
Essentially I need a way to receive mouse click on figure back into the python code. I think this is a common use case.
Thanks, I will look into Dash then. I tried to ran examples with ipwidgets but none worked for me on local python, I guess this requires Jupyter or other notebooks which I really don’t want to use.
To follow up on this, I implemented that in Dash but now encounter another problem.
My app includes a dcc.Graph with a figure containing a 3D surface plot. A click on the plot is received and processed in a callback with Input(‘opt-graph’,‘clickData’).
My issue is that the callback can’t differentiate between clicks meant to merely rotate to surface around and a clicks on a specific point on the plot that meant to fire the callback. The intention is to allow the user to first rotate the plot as they please (and perhaps zoom in and out in the process), and then have them actually select a specific point on the plot and process this choice in the callback.
Is there a way to generate another kind of click to solve that? for example, a double-click, or a right-click? Alternatively, is it possible not to have a “click and drag plot” kind of event not get registered as clickdata event? Or any other way to distinguish between the two?