plotly / plotly/plotly.py

Consider showing UTC offset in tooltip for datetimes

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

还没有人认领这个 Issue。

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

描述

Say I have

import pandas as pd
dfa = pd.DataFrame(
    {
        "datetime": ["2020-10-25T01:30"] * 2,
        "price": [40, 50],
    }
)
dfa['datetime'] = pd.to_datetime(dfa['datetime']).dt.tz_localize('Europe/London', ambiguous=[True, False])
dfa
                   datetime  price
0 2020-10-25 01:30:00+01:00     40
1 2020-10-25 01:30:00+00:00     50

and I plot

px.scatter(dfa, x="datetime", y="price")

then I get

Image

Notice how the two points are stacked one on top of each other, even though they are actually 1 hour apart

If Plotly's design decision for time zones is to display the local datetime, then I think this makes perfect sense, nice one 👍 However, I think the tooltip should give enough information to distinguish the two points, whereas currently, they both show:

datetime=Oct 25, 2020, 01:30

I would expect the bottom one to show datetime=Oct 25, 2020, 01:30 +01:00 and the top one to show datetime=Oct 25, 2020, 01:30 +00:00

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行 issue 中的 Python 复现代码,并检查 Plotly 如何在悬停提示中格式化 datetime 值。当通过显示 UTC 偏移量后,两个有歧义的 Europe/London datetime 仍然可以区分,并为此示例添加 coverage 时,即表示完成。

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

评估

技术栈
python
领域
data-visualization
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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