Skip to content

Issue with plotly.express.timeline writing to an image with kaleido #5260

Open
@shavnir

Description

@shavnir

I ran into a weird issue with plotly.express.timeline but it only shows up when you call fig.write_image, not in fig.show or fig.write_html. Basically every box in the chart gets left aligned and the x axis label starts at epoch.

Repro steps :
Ubuntu 20.04
Python - 3.10.12
PIPs installed in venv :

--------------- -----------
choreographer   1.0.9
kaleido         1.0.0
logistro        1.1.0
narwhals        1.45.0
numpy           2.2.6
orjson          3.10.18
packaging       25.0
pandas          2.3.0
pip             22.0.2
plotly          6.2.0
python-dateutil 2.9.0.post0
pytz            2025.2
setuptools      59.6.0
simplejson      3.20.1
six             1.17.0
tzdata          2025.2

Test code :

import pandas as pd
import datetime
import plotly.express as px

df = pd.DataFrame({
    "Task": ["A", "B"],
    "Start": [datetime.datetime.fromtimestamp(1720000000), datetime.datetime.fromtimestamp(1720003600)],
    "Finish": [datetime.datetime.fromtimestamp(1720007200), datetime.datetime.fromtimestamp(1720010800)]
})

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.write_image("test.png")

The resulting test.png has two bars of equal length both left aligned starting at Jan 1 1970. If you put a fig.show() it shows the two bars offset as you would expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1needed for current cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions