px.timeline Incorrectly interprets x_end datetimes
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
The px.timeline function incorrectly generates the end times of the bar traces. The end times are placed before the start times.
Python version 3.8.6
Plotly version 5.4
Steps to reproduce:
import datetime
import plotly.express as px
t0 = datetime.datetime.now()
tf = t0 + datetime.timedelta(hours=1)
px.timeline(x_start=[t0], x_end=[tf])
print(t0)
print(tf)
Produces
2021-11-16 12:21:14.800827 # t0
2021-11-16 13:21:14.800827 # tf
The resulting figure is below. Notice that the right edge of the bar is the same as the start time, but the left edge of the bar is something else entirely.

The behavior is the same when passing a dataframe and column names. If you generate a scatter plot using the same datetime objects, the output works as expected (shown below).

贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 px.timeline 入口点开始,使用报告中显示的 datetime 值重现该问题,并将其 bar trace 的坐标与使用相同值的散点图进行比较。跟踪 x_start 和 x_end 如何转换到 figure 中,然后验证生成的 bar 是否具有预期的开始和结束时间,以及 dataframe-and-column-names 情况是否也能正确运行。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100