Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.7k
Open
Description
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.9kaleido 1.0.0logistro 1.1.0narwhals 1.45.0numpy 2.2.6orjson 3.10.18packaging 25.0pandas 2.3.0pip 22.0.2plotly 6.2.0python-dateutil 2.9.0.post0pytz 2025.2setuptools 59.6.0simplejson 3.20.1six 1.17.0tzdata 2025.2
Test code :
importpandasaspdimportdatetimeimportplotly.expressaspxdf=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.