Skip to content

Plotly Express not displaying datetime #5101

Closed

Description

@Joshua-Powell-Lambda

the x-axis of my graph is displaying as the ns value of the timestamp, 1715000000000000000, instead of the corresponding readable timestamp.

The code is

        fig = go.Figure()
        local_df["reservation_start_week_utc"] = pd.to_datetime(local_df[
            "reservation_start_week_utc"
        ].apply(lambda x: pd.Timestamp(x).to_pydatetime()))

        fig.add_trace(
            go.Scatter(
                x=local_df["reservation_start_week_utc"],
                y=local_df["weighted_average_price"],
...

the datatype of the column that populates my x-axis is datetime64[ns, UTC]
I tried casting to different types, and also several different format settings on the plot. I couldnt get it to work. Rolling back plotly immediately fixed the bug

python versions used 3.13 and 3.10 no difference.

rolling back from plotly 6.0.1 to 5.24.1 fixed the formatting issue

Activity

  1. added
    bugsomething broken
    P1needed for current cycle
    on Mar 21, 2025
  2. TermeHansen commented on Apr 4, 2025

    @TermeHansen

    I see the same issue and is also back to version 5 for now...

  3. emilykl commented on Nov 10, 2025

    @emilykl
    Contributor

    Hi @Joshua-Powell-Lambda , could you let me know whether you still experience this issue with plotly==6.4.0?

    I can't completely recreate your example since I don't know the contents of local_df, but I wrote the following as a best guess:

    import pandas as pd
    import plotly.graph_objs as go
    
    local_df = pd.DataFrame(
        {
            "reservation_start_week_utc": ["2024-10-07", "2024-10-14", "2024-10-21"],
            "weighted_average_price": [100, 150, 120],
        }
    )
    
    local_df["reservation_start_week_utc"] = pd.to_datetime(
        local_df["reservation_start_week_utc"].apply(
            lambda x: pd.Timestamp(x).to_pydatetime()
        )
    )
    
    fig = go.Figure()
    fig.add_trace(
        go.Scatter(
            x=local_df["reservation_start_week_utc"],
            y=local_df["weighted_average_price"],
        )
    )
    fig.show()

    Running the above code with plotly==6.4.0 gives me the following plot:

    Image

    which looks correct.

    Let me know if you still experience the issue with the latest Plotly. And if so, if you can provide a complete code example to reproduce the issue, that would be very helpful. I am investigating a similar issue right now (#5355) so I would like to cover this issue with the fix as well, if it is still a problem. Thanks!

  4. emilykl commented on Sep 2, 2026

    @emilykl
    Contributor

    Closing since I suspect this is resolved; please go ahead and open a new issue if the problem persists in plotly.py >= v7.0.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