You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kaleido 1.0.0rc0 can't plot datetimes as axis label correctly when renderer=“png” #236
in kaleido 1.0.0rc0, when set renderer="png", Plotly plot datetime as int as axis label, when set renderer="plot_mimetype", Plotly plot datetime correctly as axis label.
in Kaleido 0.2.1, no matter renderer="png" or renderer="plot_mimetype", Plotly can both plot datetime correctly as axis label.
Smame here, I encountered this issue when exporting figures with every format in version 1.0.0 fig.write_image("xxx")
The exported file is not rendered correctly, although the figure displays properly within the Jupyter Notebook output.
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
Reacted by Henry, fischbone, dsjoho and Michael A.
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
When running the same script in the local macOS Jupyter environment, the output is normal. However, issues arise when using it on a remote Linux workstation.
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
Thanks! This helped me solve my plotly timeline that suddenly started from 1970: df["start"] = df["start"].astype('datetime64[us]').
Before that I tried just .dt.date, but it didn't work.
Reacted by Michael A., channenghsu, Elias Talcott, Harang Ju and Matthias Zeeman
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
Thanks! This helped me solve my plotly timeline that suddenly started from 1970: df["start"] = df["start"].astype('datetime64[us]'). Before that I tried just .dt.date, but it didn't work.
Great! Then a start-point for an expensive workaround - until this issue is expertly fixed on the kaleido side - is by looping over columns and (multi-)index of the input data and testing for is_datetime64_ns_dtype:
df= ... # some input DataFrame passed later to plotly express # columnsforninlist(df.columns):
ifpd.core.dtypes.common.is_datetime64_ns_dtype(df[n]):
df[n] =df[n].astype("datetime64[us]")
# indexforninlist(df.index.names):
ifpd.core.dtypes.common.is_datetime64_ns_dtype(
df.index.get_level_values(df.index.names.index(n))
):
df.index=df.index.set_levels(
df.index.get_level_values(df.index.names.index(n)).astype("datetime64[us]"),
level=df.index.names.index(n),
)
... probably does not go well on duplicate names. Needs improvement.
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
Thanks! This helped me solve my plotly timeline that suddenly started from 1970: df["start"] = df["start"].astype('datetime64[us]'). Before that I tried just .dt.date, but it didn't work.
Great! Then a start-point for an expensive workaround - until this issue is expertly fixed on the kaleido side - is by looping over columns and (multi-)index of the input data and testing for is_datetime64_ns_dtype:
df = ... # some input DataFrame passed later to plotly express
columns
for n in list(df.columns):
if pd.core.dtypes.common.is_datetime64_ns_dtype(df[n]):
df[n] = df[n].astype("datetime64[us]")
index
for n in list(df.index.names):
if pd.core.dtypes.common.is_datetime64_ns_dtype(
df.index.get_level_values(df.index.names.index(n))
):
df.index = df.index.set_levels(
df.index.get_level_values(df.index.names.index(n)).astype("datetime64[us]"),
level=df.index.names.index(n),
)
... probably does not go well on duplicate names. Needs improvement.
As far as re-casting the columns go, you could probably do something like dt = dt.astype({col: "datetime64[us]" for col in dt.select_dtypes("datetime64")}), or if you want to use narwhals, you could do something like df = nw.from_native(df).with_columns(ncs.by_dtype(nw.Datetime("ns")).cast(nw.Datetime("us"))).to_native().
Activity
ayjayt commentedon Dec 16, 2024
Hi! Thanks for this, I'm going to mark it active.
I think its solved in an unreleased but already-merged pr (which may come out tomorrow or the day after).
valankar commentedon Apr 21, 2025
Just came across this as well trying to switch to 1.0.0.
rod7760 commentedon Jun 27, 2025
I am seeing this with every format for
fig.writefor 1.0.0So the issue title might be a bit misleading.
chetanpat93 commentedon Aug 5, 2025
Does anyone have a resultion on this?
forest009839 commentedon Sep 12, 2025
Smame here, I encountered this issue when exporting figures with every format in version 1.0.0
fig.write_image("xxx")The exported file is not rendered correctly, although the figure displays properly within the Jupyter Notebook output.
BlastoiseBlue commentedon Sep 23, 2025
It looks like the issue happens specifically when the timestamps have nanosecond resolution, which is what pandas uses by default. Changing the resolution to microseconds does seem to fix this, but it's not ideal for pandas' default behavior to cause issues like this.
forest009839 commentedon Sep 29, 2025
When running the same script in the local macOS Jupyter environment, the output is normal. However, issues arise when using it on a remote Linux workstation.
dsjoho commentedon Oct 1, 2025
Thanks! This helped me solve my plotly timeline that suddenly started from 1970:
df["start"] = df["start"].astype('datetime64[us]').Before that I tried just
.dt.date, but it didn't work.z--m-n commentedon Oct 16, 2025
Great! Then a start-point for an expensive workaround - until this issue is expertly fixed on the kaleido side - is by looping over columns and (multi-)index of the input data and testing for
is_datetime64_ns_dtype:... probably does not go well on duplicate names. Needs improvement.
BlastoiseBlue commentedon Oct 16, 2025
As far as re-casting the columns go, you could probably do something like
dt = dt.astype({col: "datetime64[us]" for col in dt.select_dtypes("datetime64")}), or if you want to use narwhals, you could do something likedf = nw.from_native(df).with_columns(ncs.by_dtype(nw.Datetime("ns")).cast(nw.Datetime("us"))).to_native().boomshankerx commentedon Oct 16, 2025
@Honghe Nerd points for
go.Figure()emilykl commentedon Nov 10, 2025
@Honghe @ayjayt Has this specific issue been resolved? I am not able to reproduce with
plotly==6.4.0andkaleido==1.2.0.This code:
produces this image:

which looks correct.
However, there are still some similar issues with
[ns]precision datetimes in Plotly.py (e.g. plotly/plotly.py#5355) which I am investigating.ayjayt commentedon Nov 11, 2025
I just tested it under kaleido==1.2.0 for all png, jpg, svg, and pdf and got the same image for all- equal to yours. Closing.
(this was likely fixed in v1.2.0!)