plotly / plotly/plotly.py

Incorrect fill in graph objects when connectgaps is set to false

Đang mở
#5,105 3 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ả

Whenever a graph object has the following parameters:
First series -> fill='tonexty',
Second series -> connectgaps=False

The fill connects the first point of this series with the first point of the last segment after "gaps" from the second series, instead of its respective first value.

Here is a basic example

import plotly.graph_objects as go

fig = go.Figure()

def remove_from_list(lst, idx):
    return lst[:idx] + [None] + lst[idx+1:]

x = [i for i in range(5)]

y = [1 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=remove_from_list(y, 2),
    connectgaps=False
))

y = [2 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=y,
    fill='tonexty',
))

fig.show()

Image

Here is another example with more than 1 gap in the data:

import plotly.graph_objects as go

fig = go.Figure()

def remove_from_list(lst, idx):
    return lst[:idx] + [None] + lst[idx+1:]

x = [i for i in range(8)]

y = [1 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=remove_from_list(remove_from_list(y, 2), 5),
    connectgaps=False
))

y = [2 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=y,
    fill='tonexty',
))

fig.show()

Image

I've also attached their respective figure outuputs.

Finally, I have an additional comment regarding how areas are filled.
The following shows another basic example with gaps in both series, and both with connectgaps=False.

import plotly.graph_objects as go

fig = go.Figure()

def remove_from_list(lst, idx):
    return lst[:idx] + [None] + lst[idx+1:]

x = [i for i in range(5)]

y = [1 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=remove_from_list(y, 2),
    connectgaps=False
))

y = [2 for _ in x]
fig.add_trace(go.Scatter(
    x=x,
    y=remove_from_list(y, 2),
    fill='tonexty',
    connectgaps=False
))

fig.show()

The connected area spans even the places where the values are undefined (during a gap). My expectation would be the opposite:
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

Không có tệp mã nguồn hoặc bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng cách chạy các ví dụ Python được cung cấp với plotly.graph_objects và so sánh các vùng tô được kết xuất xung quanh các giá trị None khi connectgaps=False. Hoàn thành khi các vùng tô sử dụng các phân đoạn tương ứng của chuỗi và không kéo dài qua các khoảng trống không xác định; hãy bổ sung kiểm thử hồi quy cho các trường hợp được minh họa.

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.