I’m trying to create an animated map where each marker is plotted sequentially and cumulatively, ie. 1 marker, 2, 3, et al. I’ve been trying to use this as an example but am stumped because it looks like the first trace is plotted, then all traces (rather than sequential frames). Any help would be greatly appreciated.
import pandas as pd
import plotly.plotly as py
from plotly.graph_objs import *
from plotly.grid_objs import Grid, Column
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
mapbox_access_token = ''
filename = "https://raw.githubusercontent.com/spencerlawrence36/basic/master/places.csv"
df = pd.read_csv(filename, encoding='utf-8')
df = df.head(100)
trace1 = [Scattermapbox(
lat=['33.49'],
lon=['-112.05'],
mode='markers',
marker=Marker(
size=15,
color='#000000'
)
),
]
layout = Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=dict(
lat=33.49,
lon=-112.05
),
pitch=0,
zoom=10,
style='light'
)
)
frame_list, lat_list, lon_list = [], [], []
for x in range(df.shape[0]):
df_lat = df.iloc[x,1]
df_lon = df.iloc[x,0]
lat_list.append(df_lat)
lon_list.append(df_lon)
frame_trace = [Scattermapbox(
lat=lat_list,
lon=lon_list,
mode='markers',
marker=Marker(
size=15,
color='#000000'
)
)]
frame = dict(
data = frame_trace,
name=str(x),
traces=[0]
)
frame_list.append(frame)
data=trace1
fig = dict(data=data, layout=layout, frames=frame_list)
plot(fig, filename='place_map.html')