plotly / plotly/plotly.py

Consider showing UTC offset in tooltip for datetimes

Open
#4,844 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P2
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Python reproduction in the issue and inspect how Plotly formats datetime values in hover tooltips. Done means the two ambiguous Europe/London datetimes remain distinguishable by showing their UTC offsets, with coverage added for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.