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/#/