plotly / plotly/plotly.py

Static image excludes layout_images if source is not absolute path

Đang mở
#4,548 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P3
Ngôn ngữ chính
Python
Star
18.8k
Fork
2.8k
Merge trung bình
16 giờ 26 phút
Pull request đã merge (30 ngày)
21

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ với nguồn layout-image tương đối, so sánh fig.write_image() và plotly.io.to_image() với trường hợp đường dẫn tuyệt đối. Được xem là hoàn tất khi layout-image có đường dẫn tương đối xuất hiện trong các bản xuất tĩnh từ cả hai phương thức mà không có lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.