✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Can I create plots on my scatter by using my mouse?

Hi all, I’m fairly new to plotly. I’m having a hard time trying to get my plotly graph to be interactive.

I have a scatter plot displayed on my browser - but as a user I want to be able to move those plots around or add in a new plot by clicking on where I want it on the graph.

Can anyone point me in the right direction for this fix?

Thank y’all so much!

Hi @Hobbitbob welcome to the forum! Have you already read through the documentation page on click events? You could adapt one of these examples so that for example when you click somewhere in the figure, the closest data points moves to the clicked position. However, not that in plotly you can only click on data points, not at arbitrary positions on the canvas, so you would have to define for example a Heatmap trace (of transparent pixels, without hover so that the user does not see it) below the scatter so that you can click everywhere and capture the position.

Another solution is to use layout shapes instead of scatter points, but then you will not have hover information. Adding shapes by clicking is under development and should be included in the next plotly.js release.

1 Like

Thank you so much for the response!!