May I ask how to show a continuous color scale in the following Scatter3d chart in which the color of the points/marker is associated with a variable of float value “df_frame[‘cen_z’]”?
When I added showlegend=True
in .update_layout()
, only a trace o
dot legend is shown…
Code:
fig_frame_cen = go.Figure(
data=[go.Scatter3d(
x = df_frames['cen_x'],
y = df_frames['cen_y'],
z = df_frames['cen_z'],
mode='markers',
marker = dict(
size=2,
color=df_frames['cen_z'],
colorscale='Viridis',
opacity=0.8,
),
text='id:' + df_frames['id'],
)],
)
fig_frame_cen.update_scenes(
aspectmode='data',
aspectratio=dict(x=1, y=1, z=0.001),
camera=dict(
eye=dict(x=1, y=-5, z=5)
)
)
fig_frame_cen.update_layout(
title=dict(
text='Positions of Centers',
x=0.5,
),
showlegend=True,
)
fig_frame_cen.show()