Having issues getting a background image to appear in my dash plots. I’ve attached a working example that tried to insert the same image (python logo) as in this example, which works: https://plot.ly/python/images/
I’ve tried to make this work multiple ways, but have been unable to make an image appear as soon as I get into Dash.
The only solution I’ve found so far in my search seems to be encoding the image via base64 https://stackoverflow.com/a/50588855 - is this really the only option? I tried a naiive implementation of this stack overflow example and it still didn’t work. A number of other users seem to be having the same issue.
Would really appreciate an assist here! Thank you for reading
import dash_core_components as dcc
import plotly.graph_objs as go
import dash_html_components as html
import dash
app = dash.Dash()
app.layout = html.Div(children = [dcc.Graph(
figure=go.Figure(
data=[
go.Bar(
x=[1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012],
y=[219, 146, 112, 127, 124, 180, 236, 207, 236, 263,
350, 430, 474, 526, 488, 537, 500, 439],
name='Rest of world',
marker = dict(
color='rgb(55, 83, 109)'
)
),
go.Bar(
x=[1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012],
y=[16, 13, 10, 11, 28, 37, 43, 55, 56, 88, 105, 156, 270,
299, 340, 403, 549, 499],
name='China',
marker = dict(
color='rgb(26, 118, 255)'
)
)
],
layout=go.Layout(
title='US Export of Plastic Scrap',
margin = dict(l=40, r=0, t=40, b=30),
images = [
dict(
source= "https://images.plot.ly/language-icons/api-home/python-logo.png",
xref= "x",
yref= "y",
x= 0,
y= 500,
sizex= 2000,
sizey= 500,
sizing= "fill",
opacity= 0.7,
visible = True,
layer= "below")]
)
),
style={'height': 600},
id='my-graph'
)])
app.css.append_css({
'external_url': 'https://codepen.io/illsci/pen/wxZMQm.css'
})
if __name__ == '__main__':
app.run_server(threaded = True)