plotly / plotly/plotly.py

Bar plot hover shows incorrect bar length when base is used

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

Hello,

I tried making something like a Gantt chart and use the Bar plot type for that. It seems the hover effect is mixing up the columns somehow. Here is a minimal reproduction:

import pandas as pd
import plotly.express as px

gantt = []
gantt.append(dict(Begin=0, End=1, Word='Foo'))
gantt.append(dict(Begin=2, End=5, Word='Bar'))
gantt_df = pd.DataFrame(gantt)
gantt_df['Duration'] = (gantt_df['End'] - gantt_df['Begin'])

fig = px.bar(gantt_df, base="Begin", y="Duration", x="Word")
fig.show()

Here is the result:
image

Things of note:

  • The position and size of the bars is correct
  • The "Begin" annotation in the hover is correct
  • The "Duration" annotation shows the value of the "End" column, which is not correct. I would expect "End=5" or "Duration=3" but not "Duration=5"

Examining the pandas dataframe itself shows that the data itself is correct:
image

This is my version according to conda:
plotly 5.23.0 pyhd8ed1ab_0 conda-forge

Thank you for providing this great library for free and I hope that you find my report helpful.

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 chạy bản tái hiện tối thiểu của pandas và plotly.express từ issue với plotly 5.23.0, rồi so sánh các trường hover của thanh được hiển thị với Begin, End và Duration trong dataframe. Công việc hoàn tất khi vị trí của các thanh vẫn chính xác và hover hiển thị giá trị Duration mong đợi thay vì End.

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

Đánh giá

Công nghệ
pandas, 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
Đặc tả rõ ràng
Mức phù hợp với người mới
45/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.