Skip to content

add_vline fails with datetime64[ns] #4974

Open
@CarlAndersson

Description

@CarlAndersson

When using datetime64 from numpy with nanosecond precision, the add_vline method does not show any vlines.

Reproducible as follows:

import plotly.graph_objects as go
import numpy as np

t = np.arange(120).astype("timedelta64[s]") + np.datetime64("2025-01-14 08:00")
t = t.astype("datetime64[ns]")
y = np.linspace(0, 1, t.size)
fig = go.Figure()
fig.add_scatter(x=t, y=y)
fig.add_vline(x=t[5])
  • Removing the conversion to "datetime64[ns]" makes the vline appear.
  • Converting to "h", "m", "s", "ms" or "us" all seem to work. (The time spacing have to be modified for hours or minutes.)
  • Converting only the time input to add_vline also resolves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions