Skip to content

plotly 6.3.0 does not work with numpy datetime #5355

Closed

Description

@StageTired

I upgraded my requirements from plotly==5.9.0 to plotly==6.3.0 and observed a regression. Markers on the plot disappeared without any error.

Simply put, my code takes a figure as input and plots a dot at the end of each line. Simple reproducible example:

import numpy as np
import pandas as pd
import plotly.graph_objs as pgo
import plotly.subplots

np.random.seed(42)

# random data
dates = pd.date_range(start="2025-01-01", periods=3, freq="D")
data = np.random.randn(3, 1)
df = pd.DataFrame(data, index=dates, columns=["value"])

# this is plotted elsewhere
fig = plotly.subplots.make_subplots()

for column in df.columns:
    trace = pgo.Scatter(
        x=df.index,
        y=df[column],
        mode="lines",
    )

    fig.add_trace(trace)

# take the figure and
# render last point of each line using fig.data
for i, trace in enumerate(fig.data):
    input_x = trace.x[-1]
    input_y = trace.y[-1]
    print("Input x:", input_x, type(input_x))
    print("Input y:", input_y, type(input_y))

    fig.add_scatter(
        x=(input_x,),
        y=(input_y,),
        mode="markers+text",
    )
    print(f"Plotted x value:", fig.data[-1].x)

fig.show()

If I run this with different plotly versions I get different type for the timestamp:

Image

With plotly<6, the figure looks like this

Image With plotly>=6, it looks like this Image

I am aware that I can convert numpy datetime back to datetime.datetime to fix my problem but why does plotly treat numpy datetime as a unix timestamp? It's not being converted to an actual date and there is no error either.
Simply put I would expect x axis to be a date and not an impossibly large number:

import numpy as np
import plotly.subplots

fig = plotly.subplots.make_subplots()

x = np.datetime64('2025-09-26T01:00:00.000000000')
y = 1.23

fig.add_scatter(
    x=(x,),
    y=(y,),
    mode="markers+text",
)
print(f"Plotted x value:", fig.data[-1].x)

fig.show()
Image

Activity

  1. changed the title [-]Question. Why does plotly not work with numpy datetime[/-] [+]plotly 5.3.0 does not work with numpy datetime[/+] on Oct 1, 2025
  2. added
    bugsomething broken
    P1needed for current cycle
    on Oct 1, 2025
  3. changed the title [-]plotly 5.3.0 does not work with numpy datetime[/-] [+]plotly 6.3.0 does not work with numpy datetime[/+] on Oct 2, 2025
  4. boomshankerx commented on Oct 13, 2025

    @boomshankerx

    Is there a workaround for this other than downgrading plotly and kaleido?

  5. BlastoiseBlue commented on Oct 16, 2025

    @BlastoiseBlue

    Is there a workaround for this other than downgrading plotly and kaleido?

    Try converting the timestamps to a different precision, such as datetime64[us] plotly/kaleido#236 (comment)

  6. ayjayt commented on Nov 4, 2025

    @ayjayt
    Contributor

    This should be fixed with v1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1needed for current cyclebugsomething brokenregressionthis used to work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions