enable plotting vs time on 23 and 25 hour days
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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()


Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the spring-forward and fall-back examples in the issue and compare the plotted spacing with the expected 23- and 25-hour timelines. Review the related issues #171 and #4358 before deciding the scope. Done means the issue's requested DST-aware plotting behavior is supported without changing behavior when no timezone or flag is provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100