How to move the image per frame in scatterplot?

Hey Plotly community,

I have a px scatterplot with animation frame. I want to have images on the scatter plot and be able to move together with it.

However, px.add_layout results in having the images plotted directly, how can I show it per frame? I try to search on fig.frames but couldn’t find the parameters to add images.

This is the code for the plot now:

x_list = [22.0,
 15.0,
 10.0,
 477.0,
 485.0,
 8.0,
 16.0,
 24.0,
 16.0,
 485.0,
 24.0,
 8.0,
 8.0,
 24.0,
 16.0,
 485.0,
 8.0,
 16.0,
 485.0,
 24.0,
 485.0,
 16.0,
 8.0,
 24.0,
 486.0,
 8.0,
 22.0,
 26.0,
 26.0,
 473.0,
 23.0,
 22.0,
 475.0,
 26.0,
 30.0,
 23.0,
 475.0,
 23.0,
 30.0,
 26.0,
 23.0,
 30.0,
 476.0,
 26.0,
 23.0,
 30.0,
 469.0,
 26.0,
 26.0,
 472.0,
 30.0,
 23.0,
 23.0,
 30.0,
 26.0,
 469.0,
 30.0,
 23.0,
 469.0,
 26.0,
 23.0,
 30.0,
 469.0,
 26.0,
 450.0,
 50.0,
 36.0,
 28.0,
 46.0,
 430.0,
 38.0,
 72.0,
 95.0,
 59.0,
 411.0,
 50.0,
 67.0,
 118.0,
 73.0,
 392.0]
y_list = [23.0,
 13.0,
 19.0,
 484.0,
 473.0,
 17.0,
 8.0,
 24.0,
 8.0,
 473.0,
 24.0,
 17.0,
 17.0,
 24.0,
 8.0,
 473.0,
 17.0,
 8.0,
 473.0,
 24.0,
 473.0,
 8.0,
 17.0,
 24.0,
 469.0,
 17.0,
 25.0,
 27.0,
 27.0,
 476.0,
 29.0,
 22.0,
 477.0,
 27.0,
 24.0,
 29.0,
 476.0,
 29.0,
 24.0,
 27.0,
 29.0,
 24.0,
 481.0,
 27.0,
 29.0,
 24.0,
 478.0,
 27.0,
 27.0,
 479.0,
 24.0,
 29.0,
 29.0,
 24.0,
 27.0,
 478.0,
 24.0,
 29.0,
 478.0,
 27.0,
 29.0,
 24.0,
 478.0,
 27.0,
 469.0,
 29.0,
 47.0,
 38.0,
 67.0,
 457.0,
 58.0,
 32.0,
 35.0,
 86.0,
 443.0,
 78.0,
 92.0,
 37.0,
 105.0,
 429.0]
icon_list = ['https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1257.png',
 'https://cdn-icons-png.flaticon.com/512/1/1848.png',
 'https://cdn-icons-png.flaticon.com/512/0/27.png',
 'https://cdn-icons-png.flaticon.com/512/0/619.png']
gametime_list = ['00:00:00',
 '00:00:00',
 '00:00:00',
 '00:00:00',
 '00:00:01',
 '00:00:01',
 '00:00:01',
 '00:00:01',
 '00:00:02',
 '00:00:02',
 '00:00:02',
 '00:00:02',
 '00:00:03',
 '00:00:03',
 '00:00:03',
 '00:00:03',
 '00:00:04',
 '00:00:04',
 '00:00:04',
 '00:00:04',
 '00:00:05',
 '00:00:05',
 '00:00:05',
 '00:00:05',
 '00:00:06',
 '00:00:06',
 '00:00:06',
 '00:00:06',
 '00:00:07',
 '00:00:07',
 '00:00:07',
 '00:00:07',
 '00:00:08',
 '00:00:08',
 '00:00:08',
 '00:00:08',
 '00:00:09',
 '00:00:09',
 '00:00:09',
 '00:00:09',
 '00:00:10',
 '00:00:10',
 '00:00:10',
 '00:00:10',
 '00:00:11',
 '00:00:11',
 '00:00:11',
 '00:00:11',
 '00:00:12',
 '00:00:12',
 '00:00:12',
 '00:00:12',
 '00:00:13',
 '00:00:13',
 '00:00:13',
 '00:00:13',
 '00:00:14',
 '00:00:14',
 '00:00:14',
 '00:00:14',
 '00:00:15',
 '00:00:15',
 '00:00:15',
 '00:00:15',
 '00:00:16',
 '00:00:16',
 '00:00:16',
 '00:00:16',
 '00:00:17',
 '00:00:17',
 '00:00:17',
 '00:00:17',
 '00:00:18',
 '00:00:18',
 '00:00:18',
 '00:00:18',
 '00:00:19',
 '00:00:19',
 '00:00:19',
 '00:00:19']
color_list = ['blue',
 'blue',
 'blue',
 'red',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'red',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'red',
 'blue',
 'blue',
 'blue',
 'blue',
 'red']
size_list = [20] * 80

fig = px.scatter(df, x="x", y="y", animation_frame="gametime", animation_group="icon", 
                 color="team",
                 log_x=False, size="size", range_x=[0,500], range_y=[0,500], width=800, height=800)


# ===
# The images are now shown immediately, but I want to have it on the scatter point
# ===
for x,y, png in zip(df['x'], df['y'], df['icon']):
    fig.add_layout_image(
        layer="above",
        x=x,
        y=y,
        source=png,
        xref="x",
        yref="y",
        sizex=17,
        sizey=17,
        xanchor="center",
        yanchor="middle"
    )


fig.add_layout_image(
        source="https://images.plot.ly/language-icons/api-home/python-logo.png",
        xref="paper",
        yref="paper",
        x=0,
        y=1,
        xanchor="left",
        yanchor="top",
        layer="below",
        sizing="stretch",
        sizex=1.0,
        sizey=1.0
    )

fig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 250

fig.show()

Any suggestions would be appreciated, thanks in advance