Skip to content

plotly.express.scattermatrix displays no color if supplied a pandas.DataFrame with a DataTime index #4917

Closed

Description

@Noskario

The color does not get diplayed when using a DataFrame with a DateTime index.

Have a look at the following example:

import pandas as pd
import plotly.express as px
df = pd.DataFrame({
        "x":[1,2,3,4],
        "y":[10,20,10,20],
        "z":[-1,-2,-3,-4],
        "color":[1,2,3,4]
    })
df.index = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00", "3/1/2020 10:00:00+00:00", "4/1/2020 11:00:00+00:00"])
px.scatter_matrix(df, color = "color")

Image

There are no problems when you comment out the line df.index = ....

Maybe this issue is related to #4788

Activity

  1. MarcoGorelli commented on Nov 30, 2024

    @MarcoGorelli
    Contributor

    Hi @Noskario

    is this your expected output?

    if so, I might have a fix

    Image

  2. Noskario commented on Dec 2, 2024

    @Noskario
    Author

    Yes, absolutely!

  3. MarcoGorelli commented on Dec 2, 2024

    @MarcoGorelli
    Contributor

    cool, thanks! if you try

    pip install -U --pre plotly narwhals
    

    then you'll get to try out the Plotly 6.0 prerelease, which should have this fixed - if you then find and report any other issues so they can be fixed ahead of the final 6.0 release then you're a star ⭐

  4. added
    bug
    P1
    and removed
    P3
    on Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions