Relatively knew to Plotly, but I’ve been scouring everything I can to try and find some help, but have come up with nothing.
I’m using a ScatterGeo to plot the movement of a datapoint over time. This is working fine, but each frame the point jumps to the new location, instead of animating/transitioning from one spot to another. Either I’m missing something important, or the ScatterGeo plot might not support that kind of transition.
This is what I’ve got as the latest version. The df variable is a standard Pandas dataframe. Anyone know what I might be missing?
data = [go.Scattergeo(
locationmode = 'USA-states',
lon = [df.iloc[0]['lon']],
lat = [df.iloc[0]['lat']],
text = [df.iloc[0]['count']],
name = "user",
mode = 'markers',
marker = dict(
size = 5,
color = 'rgb(0,116,217)',
line = go.scattergeo.marker.Line(
width=0.5, color='rgb(40,40,40)'
),
sizemode = 'area'
)
)]
frames = [dict(data=[go.Scattergeo(
lat=[df.iloc[k]['lat']],
lon=[df.iloc[k]['lon']],
name="user"
)],
traces= [0],
name='frame{}'.format(k)) for k in range(1, 15)]
layout = go.Layout(
title = go.layout.Title(
text = '2019 Movement'
),
showlegend = False,
geo = go.layout.Geo(
scope = 'world',
projection = go.layout.geo.Projection(
type='albers usa'
),
showland = True,
landcolor = 'rgb(217, 217, 217)',
subunitwidth=1,
countrywidth=1,
subunitcolor="rgb(255, 255, 255)",
countrycolor="rgb(255, 255, 255)",
showsubunits = True,
showcountries = True
)
)
layout.update(updatemenus=[dict(type='buttons', showactive=False,
y=0,
x=1.05,
xanchor='right',
yanchor='top',
pad=dict(t=0, r=10),
buttons=[dict(label='Play',
method='animate',
args=[None, {'frame': {'duration': 500, 'redraw': False},
'fromcurrent': True, 'transition': {'duration': 300, 'easing': 'quadratic-in-out'}}
]
)
]
)
])
fig = go.Figure(data=data, layout=layout, frames=frames)
iplot(fig)
Thanks!