I have a fully working Dash application with my logo displayed over my chart.
When I use the fig.write_html(…) process, my resulting HTML file does not have my logo over the chart. Some relevant code snippets below. Is this the expected behavior?
fig.add_layout_image(
dict(
source="assets/Logo.png",
xref="paper", yref="paper",
x=1.014, y=0.79,
sizex=0.3, sizey=0.3,
xanchor="right", yanchor="bottom",
opacity=0.8
)
)
fig.write_html("file.html")
1 Like
lu-kalk
February 25, 2025, 4:44pm
2
I have the same problem. Any help would be appreciated
Have you tried using Image from PIL to open the image? would be something like this:
from PIL import Image
pyLogo = Image.open('assets/Logo.png')
## fig and everything else defined here
fig.add_layout_image(
dict(
source=pyLogo,
xref="paper", yref="paper",
x=1.014, y=0.79,
sizex=0.3, sizey=0.3,
xanchor="right", yanchor="bottom",
opacity=0.8
)
)
fig.write_html("file.html")
1 Like
lu-kalk
February 26, 2025, 1:36pm
5
aschutte:
from PIL import Image
Thanks so much! This works! My original logo was an svg which doesn’t work with PIL, but when I converted it to png it works