-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
bugsomething brokensomething broken
Description
Description
With plotly==6.3.1 and kaleido==1.1.0, I wasn't able to add shapes (add_vline, add_shape, ...) to a time-axis line plot and then use write_image. The shapes wouldn't appear on the image, or would have a wildly incorrect x-axis location.
Steps to reproduce
import pandas as pd
import plotly.express as px
x = ['2001-01-01', '2001-01-02', '2001-01-03']
y = [0, 3, 1]
x = pd.to_datetime(x) # Now Pandas Index of NumPy datetime64[ns]
fig = px.line(x=x, y=y)
fig.add_vline('2001-01-02')
fig.add_shape(type='rect', x0='2001-01-01', x1='2001-01-01 12:00:00', y0=0, y1=1)
fig.show() or fig.write_html() works fine:

fig.write_image() with .png, .svg etc. does not:

Notes
- Downgrading to
plotly==6.0andkaleido==0.2.1will causewrite_imageto work OK, so maybe a recent change. - Removing the line
pd.to_datetime(x)will also "fix" the issue, so maybe related to handling ofdatetime64[ns]insidewrite_image(as can be seen in the lower plot, it doesn't seem to recognise the x-axis as a time axis)?
Metadata
Metadata
Assignees
Labels
bugsomething brokensomething broken