I have created a 3D scatter plot of my data. This data can be divided into labeled data and non labeled data but all belonging to one instance.
The goal was to show a 3d model of this data with a difference in color for labeled and non labeled points. I also tried to add a mesh3d to get a better feel of the model. The code can be found below
Questions
- I would like to highlight a selected point in my scatter3d plot. Make it bigger / change color- whatever is visible. How can this be done via callback?
- How can I avoid my mesh3d of blocking clickable points (labeled and non-labeled)?
Code
#3d model cluster
labeled = dict(
mode = “markers”,
name = “Labeled”,
type = “scatter3d”,
opacity = 0.5,
x = df_labeled[‘x’].values,
y = df_labeled[‘y’].values,
z = df_labeled[‘z’].values,
ids = df_labeled[‘id’].values,
text = df_labeled[‘id’].values,
hoverinfo = ‘text’,
marker = dict( size=2, color=“red” )
)
nonlabeled = dict(
mode = “markers”,
name = “Non Labeled”,
type = “scatter3d”,
opacity = 0.3,
x = df_nonlabeled[‘x’].values,
y = df_nonlabeled[‘y’].values,
z = df_nonlabeled[‘z’].values,
ids = df_nonlabeled[‘id’].values,
text = df_nonlabeled[‘id’].values,
hoverinfo = ‘text’,
marker = dict( size=4, color=“blue” )
)
clusters = dict(
alphahull = 6,
name = “mesh”,
color = ‘red’,
opacity = 0.2,
type = “mesh3d”,
x = x,
y = y,
z = z,
mode = ‘markers’,
hoverinfo = ‘skip’,
showlegend = True
)
layout = dict(
title = ‘3D Point Clustering Model’,
scene = dict(
xaxis = dict( zeroline=False ),
yaxis = dict( zeroline=False ),
zaxis = dict( zeroline=False ),
),
layout = {‘clickmode’: ‘event+select’}
)
#fig= dict( data=[labeled, nonlabeled, clusters], layout=layout ) # including mesh3d - this blocks clickable points
fig = dict( data=[labeled, nonlabeled], layout=layout )
model3d = dcc.Graph(id=“myScatter3d”,figure=fig,style={‘height’: ‘650px’, ‘width’:‘800px’})