plotly / plotly/plotly.py

constraining axes leads to paper coordinates being off and to extra space between plot area and annotations

Đang mở
#4,872 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 P2
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ả

If I constrain the x-axis, a legend to the right of the plot area shows up too far to the right and paper coordinates x=0 and x=1 are no longer at the edges of the plot area. Paper coordinate x=1 should always be the right edge of the plot area. There should not be excessive trapped white space between the legend and the plot area. The constrained, no-width behavior should be similar to the unconstrained and constrained-with-width behaviors.

Here I reproduce the problem using the documentation example here:
https://plotly.com/python/axes/#fixed-ratio-axes

I'm happy to provide and diff the output JSON if that would be helpful

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
    x = [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
    y = [0,0,1,1,3,3,2,2,3,3,1,1,0,0],
    name="demo"
))

##Add some elements outside the main plot area
fig.update_layout(
        title=dict(text="Source:  Plotly Bug Report",
                   yref="container",
                   xref="paper",
                   xanchor="right",
                  x=1, y=0.005),
                  showlegend=True
)


#the current layout is reasonable -- the legend is close to the plot area and x=1 in paper coordinates is where we expect it.
fig.show()

#now we constrain the domain and it injects lots of space between the plot area and the legend
#paper coordinates no longer reference the plot area -- paper coordinate x=1 is well to the right of the plot area
fig.update_xaxes(
    range=[-1,4],  # sets the range of xaxis
    constrain="domain",  # meanwhile compresses the xaxis by decreasing its "domain"
)
fig.update_yaxes(
    scaleanchor = "x",
    scaleratio = 1
)

fig.show()

#now we specify the width and the layout becomes reasonable again

fig.update_layout(
    width = 800,
)

fig.show()

unconstrained graphic (expected behavior):
Image
constrained graphic (unexpected behavior)
Image
constrained graphic with width (expected behavior)
Image

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 với ví dụ về các trục có tỷ lệ cố định trên trang tài liệu được liên kết và chạy ba biến thể bố cục được nêu trong báo cáo. So sánh kết quả bị ràng buộc không có chiều rộng với các kết quả không bị ràng buộc và có chiều rộng tường minh; hoàn tất khi paper x=1 thẳng hàng với cạnh phải của vùng biểu đồ và không còn khoảng trống quá lớn giữa biểu đồ với chú giải hoặc chú thích.

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ó
4/5
Thời gian dự kiến
3-5 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.