How to make animated 3d scatter plot with different type of event

3D Scatter Animation - :bar_chart: Plotly Python - Plotly Community Forum

I’m trying to replicate a 3d scatter plot on a similar dataset with one extra dimension - type

x y z type timestamp
68 4 44 Normal 1668277801464
12 3 44 Type1 1668277801464

I’m hoping if i can plot type as different color in the scatter plot, thanks in advance

code so far

roomxmin = -150
roomxmax = 150
roomymin = -200
roomymax = 200
roomzmax = 265

def ConverttoTime(timezone,timestamp):
    tz = pytz.timezone(timezone)
    return datetime.fromtimestamp(timestamp/1000,tz).strftime("%Y-%m-%d %H:%M:%S")

fig.update_layout(scene=dict( camera=dict(eye=dict(x=.1, y=.6, z=0.7)),
                                    aspectmode='manual',
                                    aspectratio=dict(x=(roomtotal_x / roomtotal), y=(roomtotal_y / roomtotal), z=0.25)),
                      
                      legend=dict(
                                        orientation="h",
                                        yanchor="bottom",
                                        y=1.02,
                                        xanchor="right",
                                        x=1))

fig.update_layout(scene = dict(xaxis=dict(range=[roomxmin, roomxmax], autorange=False),
                               yaxis=dict(range=[roomymin, roomymax], autorange=False),
                               zaxis=dict(range=[0, roomzmax], autorange=False)
                               )
                  )

    
# Frames
frames = [go.Frame(data= [go.Scatter3d(x=x[:k+1],
                                       y=y[:k+1],
                                       z=z[:k+1]
                                       )
                          ],
                     traces=type[k],
                   name=f'frame{k}'      
                  )for k  in  range(len(x)-1)
          ]

fig.update(frames=frames)




def frame_args(duration):
    return {
            "frame": {"duration": duration},
            "mode": "immediate",
            "fromcurrent": True,
            "transition": {"duration": duration, "easing": "linear"},
            }

sliders = [
    {"pad": {"b": 10, "t": 60},
     "len": 0.9,
     "x": 0.1,
     "y": 0,
     
     "steps": [
                 {"args": [[f.name], frame_args(0)],
                  "label": ConverttoTime('Australia/Melbourne',df['timestamp'][k]),
                  "method": "animate",
                  } for k, f in enumerate(fig.frames)
              ]
     }
        ]

fig.update_layout(

    updatemenus = [{"buttons":[
                    {
                        "args": [None, frame_args(50)],
                        "label": "Play", 
                        "method": "animate",
                    },
                    {
                        "args": [[None], frame_args(0)],
                        "label": "Pause", 
                        "method": "animate",
                  }],
                    
                "direction": "left",
                "pad": {"r": 10, "t": 70},
                "type": "buttons",
                "x": 0.1,
                "y": 0,
            }
         ],
         sliders=sliders
    )



fig.update_layout(sliders=sliders)
fig.show()

@empet if god of all plot can help :slight_smile: