Unfortunately not. I ended up doing it manually which is unfortunate.
How did you do it manually?
With your choice of image editing software. I did it in Snagit Editor.
ah so not in the code
So the explaintion of embedding an image via code of plotly is faulty? Think its so weird, why dont they adjust it?
Hey guys, I figured out how to implement local files. In the docs they mentioned that we can pass PIL image objects instead of links, however that doesn’t work but it gave me another option which is to use base64 encoding e.g. ‘data:image/png;base64,iVBORw0KGgoAAAANSU’
So all you have to do is open your file
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
and then as source pass: source=f’data:image/png;base64,{encoded_string}’ and it worked for me! Hope that helps people in the future who find this!
Note that I’m using Python version and not R but had the same problem.
The same procedure is described in the R “plotly book”, using base64enc::dataURI
:
I am able to plot a scatter plot and display a background image sourced locally (image is proprietary data using plotly express “imshow”. I use Pillow to import the image. I am using the plotly express animation functionality that displays the scatter data as a function of time.
My issue is that when the animation is ‘running’ the background image disappears and is only redisplayed when the plot is reset.
Any one have a solution?
This works. And this also took way too long to find as a solution to what should be simple.