Use a local image as Background image in a ScatterPolar

If I have the source of the image as a web address it works just fine (left), If I have it as a local image it doesn’t appear. (right)
Any ideas?


here my code:

#left graph
layout = go.Layout(
                height=700,
                hovermode="closest",
                #title='Anillo {}'.format(anillo)
                title='EXTC',
                images= [dict(
                    source="https://images.plot.ly/language-icons/api-home/python-logo.png",
                    xref="paper", yref="paper",
                    x=0.5, y=0.5,
                    sizex=0.5, sizey=0.5,
                    xanchor="center",
                    yanchor="middle",
                    sizing="stretch",
                    layer="above")])

#right graph
import base64

image_filename = 'images/python-logo.png'
imagem_tunel = base64.b64encode(open(image_filename, 'rb').read())

layout = go.Layout(
                height=700,
                hovermode="closest",
                title='EXTC',
                images= [dict(
                    source='data:image/png;base64,{}'.format(imagem_tunel),
                    xref="paper", yref="paper",
                    x=0.5, y=0.5,
                    sizex=0.5, sizey=0.5,
                    xanchor="center",
                    yanchor="middle",
                    sizing="stretch",
                    layer="above")])

What am I doing wrong? :upside_down_face:

You have to decode the base64 encoding:

source='data:image/png;base64,{}'.format(imagem_tunel.decode()),
1 Like

@Snizl Thank you! It works just perfectly!

Have tried loading the plot in a dash enviornment? It just disappears in a dash enviornment. I dont understand how this is happening