Create animation with each frame (i.e year) having a different trace

hello,

new to plotly. I have latitude / longitude data across several years. I have done clustering on this data, and obtained cluster centers (lat/lon coordinates) for each year.

I am trying to generate a px.scatter mapbox that plots the lat / lon for each year, as well as the respective cluster centers for that year. So far, I have been able to plot the lat / lon data and ALL the cluster centers in each year; is there a way where I could separate the cluster centers into their respective frames?

Here is the code snippet:
fig = px.scatter_mapbox(result, lat=“Lat”, lon=“Lon”, animation_frame = ‘Year’,
color_discrete_sequence=[“fuchsia”], zoom = 8, color=all_kmedLabels, height=500)
fig.update_layout(mapbox_style=“open-street-map”)
fig.update_layout(margin={“r”:0,“t”:0,“l”:0,“b”:0})

fig.add_trace(go.Scattermapbox(
lat=all_med_centroids[:,0], # this adds the trace to all years, but we want it separate for each yr.
lon=all_med_centroids[:,1], #
mode=‘markers’,
marker=go.scattermapbox.Marker(
size=10,
color=‘rgb(255, 255, 255)’,
opacity=1
),
))

I have viewed this but it doesnt look like it worked for me: https://chart-studio.plotly.com/~empet/14825/scattermapbox-animation-forum-question/#/