✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Time Series animation on streetmap

Hi
I am new to plotly.
I am trying to build an animated visualization of precipitation rate of a specific lat lon through different time stamp. So far I could only build for single time stamp.
I am stuck with building the frame and slider. Please help.
Below is my code

import pandas as pd
import plotly
data=pd.read_csv("https://raw.githubusercontent.com/RajdipKhan/Climate-change-visulization/master/data_pr.csv")
data["Timee"] = pd.to_datetime(data['Timee'])#converting obj to datetime
data1=data[data['Timee']=='2019-01-01']
#Data plotting on a single timestamp 2019-01-01

import plotly.express as px

fig = px.scatter_mapbox(data1, lat="latitude", lon="longitude", hover_data=["pr"],
                        color=data1["pr"],opacity=0.7, size=data1["pr"],zoom=5, height=500)
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

Hi @rajdipkhan, welcome to the forum! You can use the animation_frame keyword argument of px.scatter_mapbox to pass a column whose categories will be used as different animation frames. In your example, it will be the Timee column, just note that it needs to be a column of strings, so that you cannot pass datetime objects. For example

import pandas as pd
import plotly
data=pd.read_csv("https://raw.githubusercontent.com/RajdipKhan/Climate-change-visulization/master/data_pr.csv")

import plotly.express as px
fig = px.scatter_mapbox(data, lat="latitude", lon="longitude", 
                                        animation_frame='Timee', hover_data=["pr"],
                                        color=data["pr"],opacity=0.7, size=data["pr"],zoom=5, height=500)
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

Thanks a lot @Emmanuelle :slight_smile:
Working fine now.