Mapbox animation [Scattermapbox, Frames, Text]


I am trying to use plotly + mapbox to make an animation.

The idea is to have scatter markers on a map, changing from frame to frame.
Each frame represents a datetime, that would be displayed on top of the graph.

I am using go.Scattermapbox with mode set to "text " to write the datetime.

So far I have run into two problems:

textposition on go.Scattermapbox doesnt seem to work properly.
I had to hard set the coordinates of the text with lat & lon.
Which results in issues if we are to zoom in/out during animation.

Every frame change works fine for the scattermapbox marker animation, but the scattermapbox datetime text flickers through frame changes.

How to prevent that?

Thank you!
E Pattaro

Hi @epattaro,

If you’d like the date text to be positioned in a stationary location on the figure (not by lat/lon), that I’d recommend using an annotation in paper coordinates. See If you want to annotation at the top-middle of the figure, you’d use something like:

layout = go.Layout(
            text='Custom annotation text',

Hope that helps,

I used the layout.annotation and it solved both issues. (the flickering on frame animation as well)


1 Like