Strange behavior of scatter_mapbox

I’m lost with the behavior of scatter_mapbox.
I have a DF with lat/lon, a date (in the form YYYY-MM-DD HH:MM:SS) and a color. I want to animate it s.t. at a given time, all rows with a given date are printed out with the associated color.

fig = px.scatter_mapbox(df,
                lat="stop_lat" ,
                height = 600,
                width = 800,

If I don’t sort by time, I have all points but the animation it’s not in the correct order (+it doesn’t respect the order)

If I sort by time, with color given, i only have few points + it doesn’t respect the colors.

Without color given, I have all the points! (but not the colors)

Is there something I do wrong?

HI @billybobz welcome!

Check the dtype of your time column of the dataframe.


Try converting it to datetime:


it’s now datetime64[ns] but same behavior

OK so it’s a known bug px animations does not show correctly colors if all colors are not in the first frame · Issue #2259 · plotly/ · GitHub all the colors needs to be somewhere on the first frame…

1 Like