Below is a simple 3D scatter plot generated with Panel + Plotly in JupyterLab.
Does anyone how to capture the clicked coordinate (x,y,z) within the Plotly chart as shown below? I need to retrieve this (x,y,z) to drive a different plot. Thanks.
import numpy as np
import plotly.graph_objs as go
import panel as pn
pn.extension('plotly')
t = np.linspace(0, 10, 50)
x, y, z = np.cos(t), np.sin(t), t
fig = go.Figure(
data=go.Scatter3d(x=x, y=y, z=z, mode='markers'),
layout=dict(title='3D Scatter Plot')
)
pn.pane.Plotly(fig)
hi @Marc, thanks for the sample code. I am totally new to Panel. I have been trying to study your code and learn how to use param. But I am still not sure how to access the click_data. Can you please show me to how print “hello world” when the click_data is triggered? Thanks.
Hi @Marc , thank you for providing this simple example. Is there a way to link this click event in Plotly 3D plot to a discrete slider? I wish to alter the values of a discrete slider based on the points I click on the 3D plot. Kindly let me know if there is a possible solution to this.
Thank you very much for your code.
I’m also new to panel and I’m struggling with it.
I tried to run your code but nothing shows up unless I add fig.show() or plot.show().
However, since the figure is displayed, I just have the 3D scatter plot without any cell popping below nore elements printing in the terminal.
What am I missing ?
Thank you in advance for your help