Skip to content

[BUG]: px.timeline draws sub-millisecond bars with zero width #5897

Open

Description

@Enricoftw

Description

Sub-millisecond events, such as a 500 µs event in a process log, disappear from px.timeline because their bars have zero width. A 1.5 ms event is drawn as 1 ms. With pandas, a 1001 ms bar can also be drawn as 1000 ms.

cen reported the same symptom with a process log.

Screenshots/Video

fig.show() in the snippet below shows the empty pulse row.

Steps to reproduce

import plotly.express as px

df = {
    "start": ["2026-01-01 00:00:00.000000"] * 2,
    "end": ["2026-01-01 00:00:00.000500", "2026-01-01 00:00:01.001000"],
    "event": ["pulse", "dwell"],
}
fig = px.timeline(df, x_start="start", x_end="end", y="event")
print(fig.data[0].x.tolist())  # actual [0, 1000], expected [0.5, 1001.0]
fig.show()

Notes

Plotly 7.1.0, main and 6.0.0 give the actual result (Windows, Python 3.12, pandas 3.1 and 2.3). Plotly 5.24.1 gives the expected result.

process_dataframe_timeline calls Narwhals' dt.total_milliseconds(), which drops fractions and can round down with pandas. I have a fix ready and will open a PR for it.

AI disclosure: I used Codex (GPT-6.2 Sol) and Claude Code (Claude Opus 5.5) to find this, Claude Code (Claude Opus 5.5) to write this report, and Codex (GPT-6.2 Sol), Antigravity CLI (Gemini 4 Neon) and a second Claude Code session to review it. I ran the reproducer myself. I read and understood it before posting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions