Static image excludes layout_images if source is not absolute path
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 18.8k
- Forks
- 2.8k
- Merge moyen
- 16 h 26 min
- PR mergées (30 j)
- 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?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’exemple avec une source layout-image relative, en comparant fig.write_image() et plotly.io.to_image() avec le cas d’un chemin absolu. La tâche est terminée lorsque l’image layout avec un chemin relatif apparaît dans les exports statiques des deux méthodes sans erreur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100