plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

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

Open shavnir opened this issue 6 months ago • 2 comments

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.

shavnir avatar Jul 02 '25 19:07 shavnir

thanks @shavnir - we'll see if we can track it down. cc @ayjayt

gvwilson avatar Jul 03 '25 14:07 gvwilson

Hi @shavnir, with plotly==6.4.0 and kaleido==1.2.0, your code results in the following image:

Image

which looks correct to me. Could you confirm whether you are still seeing a problem with the latest plotly and kaleido versions?

emilykl avatar Nov 11 '25 15:11 emilykl