Static image excludes layout_images if source is not absolute path
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Hi there, I am currently failing to export a static image including a layout image.
The export does not show any errors but the layout images are just omitted in the exported data.
This is the case for fig.write_image() as well as plotly.io.to_image().
A simple example is:
import plotly.graph_objects as go
import numpy as np
x = np.linspace(0,3*np.pi,1000)
y = np.sin(x)
plotly_logo="Images/plotly.png"
fig = go.Figure(go.Scatter(x=x,y=y))
fig.add_layout_image(dict(
source=plotly_logo,
xref="paper",
yref="paper",
x=.5,
y=.5,
xanchor="center",
yanchor="middle",
sizex=.4,
sizey=.4
))
fig.write_image("Images/test.png", scale=3)
The image will be saved and show the sine curve but the plotly logo will not be visible.
But fig.show() shows the plotly logo nicely centered in the graph.
Switching out the relative path Images/plotly.png with a absolute one e.g. /home/user/Images/plotly.png the logo appears in the exported image file as well.
For me it seems, that the source argument is interpreted differently for different methods of showing the image.
Maybe someone knows, where to look to fix this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with a relative layout-image source, comparing fig.write_image() and plotly.io.to_image() with the absolute-path case. Done means the relative-path layout image appears in static exports from both methods without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100