Skip to content

Pandas DateTimeIndex x-axis no longer date #5231

@miohtama

Description

@miohtama

After upgrading to Plotly 6.x x-axis as DateTimeIndex is not automatically detected as a time x-axis. Instead, it looks like it is UNIX epoch seconds or nanoseconds. Now on Plotly 6.1.2.

Image

This worked in Plotly 5.x.

As a workaround one can manually cast DateTimeIndex to a list of Python datetime instances to fix the issue, but this is a bit cumbersome.

Works:

    index = df.index.to_pydatetime().tolist()

    # Price chart (top subplot)
    fig.add_trace({
        "x": index,
        "y": df["mark_price"],
        "type": "scatter",
        "mode": "lines",
        "name": "Price",
        "line": {"width": 2},
        "showlegend": False
    }, row=1, col=1)

Does not work and produced the screenshot above:

    # Price chart (top subplot)
    fig.add_trace({
        "x": df.index,
        "y": df["mark_price"],
        "type": "scatter",
        "mode": "lines",
        "name": "Price",
        "line": {"width": 2},
        "showlegend": False
    }, row=1, col=1)

Activity

miohtama

miohtama commented on Jun 17, 2025

@miohtama
Author

Duplicate of #5210

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @miohtama

        Issue actions

          Pandas DateTimeIndex x-axis no longer date · Issue #5231 · plotly/plotly.py