I am using plotlty under Jupyter Notebook to draw the figures below. And I’d like to capture the coordinates when I clik anywhere on the figure. I can’t find any example for this environment. Thanks!
fig1=px.line( ...
fig2=px.scatter( ...
fig3=px.scatter( ...
fig=go.Figure(data=fig1.data + fig2.data + fig3.data)
fig.update_xaxes(
scaleanchor = "y",
scaleratio = 2,
)
fig.update_layout(xaxis_range=[-5,5], yaxis_range=[-4,11.88*2+4])
fig.update_layout(
xaxis=dict(showgrid=False),
yaxis=dict(showgrid=False),
autosize=False,
width=700,
height=400
)
fig.show()
Anybody could help please?
I think this is what you’re looking for: Interactive Visualizations
The dcc.Graph
component has four attributes that can change through user-interaction: hoverData
, clickData
, selectedData
, relayoutData
. These properties update when you hover over points, click on points, or select regions of points in a graph.
This is what click data returns when you click on the point:
{
"points": [
{
"curveNumber": 1,
"pointNumber": 0,
"pointIndex": 0,
"x": 1,
"y": 3,
"bbox": {
"x0": 189.35,
"x1": 209.35,
"y0": 888.72,
"y1": 908.72
},
"customdata": [
3
]
}
]
}
This works only if you click on the point/object. I am not aware of methods that can allow to get data from clicks anywhere on the graph.