plotly / plotly/plotly.py

enable plotting vs time on 23 and 25 hour days

未关闭
#2,872 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

I'm trying to find a way to plot values over time on 23 and 25 hour days for daylight savings time (DST). Below is my example code that illustrates the problem, and the two resulting plots. The time stamps in x_23 and x_25 are all one hour apart. They reflect the "US/Pacific" time zone. In the spring forward case, I would expect to see twenty-three hours along the x-axis. And, in fall back, twenty-five. But, both times plotly shows 24. In spring forward, there is a visual gap in the spacing of the second and third markers. And, in fall back, there is a visual overlap.

A suggested approach would be to allow the programmer to optionally assign a time zone to the x-axis. In my case, I would assign US/Pacific. Then, plotly knows to adjust for DST if applicable. Might also want to allow assignment of a 'local' time zone. In that case, plotly would get the timezone from the computer on which it's running. If the programmer makes no assignment, plotly's behavior remains as is. Nobody's code gets broken.

A similar alternative would be to allow the programmer to set a flag to true if they want the behavior that is aware of DST. A value of false would keep the current behavior. Again, nobody's code gets broken.

I found two similar issues, but neither was really addressed.

https://github.com/plotly/plotly.js/issues/171
https://github.com/plotly/plotly.js/issues/4358

import plotly.graph_objects as go

# Spring Forward
x_23 = ["2001-04-01T00:00:00-08:00", "2001-04-01T01:00:00-08:00", "2001-04-01T03:00:00-07:00",
        "2001-04-01T04:00:00-07:00", "2001-04-01T05:00:00-07:00", "2001-04-01T06:00:00-07:00",
        "2001-04-01T07:00:00-07:00", "2001-04-01T08:00:00-07:00", "2001-04-01T09:00:00-07:00",
        "2001-04-01T10:00:00-07:00", "2001-04-01T11:00:00-07:00", "2001-04-01T12:00:00-07:00",
        "2001-04-01T13:00:00-07:00", "2001-04-01T14:00:00-07:00", "2001-04-01T15:00:00-07:00",
        "2001-04-01T16:00:00-07:00", "2001-04-01T17:00:00-07:00", "2001-04-01T18:00:00-07:00",
        "2001-04-01T19:00:00-07:00", "2001-04-01T20:00:00-07:00", "2001-04-01T21:00:00-07:00",
        "2001-04-01T22:00:00-07:00", "2001-04-01T23:00:00-07:00", "2001-04-02T00:00:00-07:00"]
y_23 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
fig_23 = go.Figure(data=[go.Scatter(x=x_23, y=y_23, mode="lines+markers")])
fig_23.update_layout(title="Spring Forward")
fig_23.show()

# Fall Back
x_25 = ["2001-10-28T00:00:00-07:00", "2001-10-28T01:00:00-07:00", "2001-10-28T01:00:00-08:00",
        "2001-10-28T02:00:00-08:00", "2001-10-28T03:00:00-08:00", "2001-10-28T04:00:00-08:00",
        "2001-10-28T05:00:00-08:00", "2001-10-28T06:00:00-08:00", "2001-10-28T07:00:00-08:00",
        "2001-10-28T08:00:00-08:00", "2001-10-28T09:00:00-08:00", "2001-10-28T10:00:00-08:00",
        "2001-10-28T11:00:00-08:00", "2001-10-28T12:00:00-08:00", "2001-10-28T13:00:00-08:00",
        "2001-10-28T14:00:00-08:00", "2001-10-28T15:00:00-08:00", "2001-10-28T16:00:00-08:00",
        "2001-10-28T17:00:00-08:00", "2001-10-28T18:00:00-08:00", "2001-10-28T19:00:00-08:00",
        "2001-10-28T20:00:00-08:00", "2001-10-28T21:00:00-08:00", "2001-10-28T22:00:00-08:00",
        "2001-10-28T23:00:00-08:00", "2001-10-29T00:00:00-08:00"]
y_25 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
fig_25 = go.Figure(data=[go.Scatter(x=x_25, y=y_25, mode="lines+markers")])
fig_25.update_layout(title="Fall Back")
fig_25.show()

spring_forward
fall_back

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先重现 issue 中春季调快和秋季调慢的示例,并将绘制出的间距与预期的 23 小时和 25 小时时间线进行比较。在决定范围之前,查看相关 issue #171 和 #4358。完成的标准是支持 issue 所要求的 DST-aware 绘图行为,同时在未提供时区或 flag 时不改变行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。