Black Lives Matter. Please consider donating to Black Girls Code today.

How do I add a background image with animation graph

Hi, I want to add a background image that is stored locally (jpg) to animation graph.
and the code uses

here is example code

import as px
df =
px.scatter(df, x=“gdpPercap”, y=“lifeExp”, animation_frame=“year”, animation_group=“country”,
size=“pop”, color=“continent”, hover_name=“country”,
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])


import as px
df =
fig=px.scatter(df, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])

import base64
#set a local image as a background
image_filename = 'first_plotly.png'
plotly_logo = base64.b64encode(open(image_filename, 'rb').read())

                images= [dict(
                    xref="paper", yref="paper",
                    x=0, y=1,
                    sizex=0.5, sizey=0.5,

For more image settings see

I really thank you for your help.

this “Plotly” is amazing

if I could go to see you, I’d treat you to a nice lunch for you

this is good for me :slight_smile:

have a nice day

2020년 3월 4일 (수) 오전 12:03, empet via Plotly Community Forum plot@discoursemail.com님이 작성:

1 Like