Default bar width on date axes should be smarter
Chưa có ai nhận issue này.
- 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ả
This is likely a similar issue to https://github.com/plotly/plotly.js/issues/6199
Plotly version: 6.2.0
Minimal Example
import plotly.graph_objects as go
import pandas as pd
import datetime
data = [
{"date": datetime.date(2025,7,20), "net_sales": 23.34, "gross_sales": 32.98},
{"date": datetime.date(2025,7,21), "net_sales": 45.21, "gross_sales": 68.12},
{"date": datetime.date(2025,7,22), "net_sales": 12.98, "gross_sales": 34.54},
{"date": datetime.date(2025,7,23), "net_sales": 41.32, "gross_sales": 45.32},
]
df = pd.DataFrame.from_records(data)
def make_figure(df, width=None):
fig = go.Figure()
fig.add_trace(go.Bar(
x=df['date'],
y=df['net_sales'],
xperiod=24*60*60*1000,
xperiod0=df['date'].min(),
xperiodalignment="middle"
))
fig.add_trace(go.Bar(
x=df['date'],
y=df['gross_sales'],
xperiod=24*60*60*1000,
xperiod0=df['date'].min(),
xperiodalignment="middle"
))
fig.update_layout(
xaxis={
'ticklabelmode': 'period',
'tickmode': 'auto',
'dtick': 24*60*60*1000,
'range': (df['date'].min(), df['date'].max() + datetime.timedelta(days=1))
})
fig.show(renderer="browser")
make_figure(df)
make_figure(df[0:1])
When plotting a bar chart of aggregated timeseries data, strange behaviour happens when there's only 1 data point or group. When there are multiple bars each bar is displayed as one would expect (first screenshot below), but when there's only a single data point the bar is invisible, and specifically the bar width is set to 1ms or 0.5px (second screenshot).
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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ụ Python tối thiểu trong issue và so sánh hành vi với plotly.js issue #6199. Hoàn thành khi một điểm ngày duy nhất hiển thị một thanh nhìn thấy được với độ rộng mặc định hợp lý, trong khi các thanh có nhiều điểm vẫn giữ nguyên hành vi hiện tạ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ó
- 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
- 38/100