plotly / plotly/plotly.py

px.line erratic and wrong for large x value ranges

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

Problem

Plotting a straight line from ($-X$, 0) to ($+X$, 1) for various (large) $X$ within a much smaller window results in wrong and inconsistent behavior, as demonstrated in below minimum non-working examples (using a Jupyter notebook with plotly.js v2.27.0).

I doubt that this behavior can be explained by intrinsic rounding problems, since

>>> np.interp([-0.1,0.1],[-1e17,+1e17],[0,1])
array([0.5, 0.5])

>>> np.interp([-0.1,0.1],[-1e18,+1e18],[0,1])
array([0.5, 0.5])

Examples

Data frame

df = pd.DataFrame(dict(x=[-1e17,+1e17,-1e18,+1e18],
                       y=[0,1,0,1],
                       xlimit=['±1e17','±1e17','±1e18','±1e18']))

Very tight plotting range (symmetric 0.1)

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-.1,.1],
              range_y=[0.4,0.6],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

pxLine_0_1

Slightly wider plotting range (symmetric 0.3)

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-.3,.3],
              range_y=[0.4,0.6],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

pxLine_0_3

Another plotting range (symmetric 1)

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-1,1],
              range_y=[0.4,0.6],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

pxLine_1

Another even wider plotting range (symmetric 3)

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-3,3],
              range_y=[0.4,0.6],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

pxLine_3

Apparently wide enough plotting range (symmetric 3.2)

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-3.2,3.2],
              range_y=[0.4,0.6],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

pxLine_3_2

As far as my tests go, for any range_x that is wider than about ±3, the plotting is rendered correctly:

fig = px.line(df,x='x',y='y',color='xlimit',
              range_x=[-1e17,1e17],
              range_y=[0,1],
              width=400,
              height=400,)
fig.update_traces(opacity=0.5)
fig.show()

px_Line_full

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

Tái hiện vấn đề trong một notebook Jupyter bằng cách sử dụng px.line với DataFrame được cung cấp, các giá trị range_x hẹp và plotly.js v2.27.0. So sánh các đường được render trên các phạm vi ví dụ và truy vết xem hành vi này bắt nguồn từ đường dẫn plotly.py px.line hay từ quá trình render của plotly.js; hoàn tất khi các đường trên phạm vi lớn được render nhất quán trong các trường hợp được cung cấp.

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

Đánh giá

Công nghệ
javascript, jupyter-notebook, 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.