[Python] Get color from category in Plotly Coordinates Plot

Discussão em 'Python' iniciado por Stack, Novembro 22, 2024.

  1. Stack

    Stack Membro Participativo

    I have a dataframe that looks like this: [​IMG]

    I want to crate a Coordinates Plot:

    fig = px.parallel_coordinates(newdf,
    color="Type_enc",
    dimensions=["Attack","Defense","HP","Sp.Attack","Sp.Defense","Speed"],
    color_continuous_scale=[[0, 'green'], [1, 'red']],
    color_continuous_midpoint=0.5,
    title ="Pokemon Stats by Type")
    fig.show()


    And the result looks like this: [​IMG]

    How do I change to legend to a discrete scale? So that instead of the encoded number, I just get "Fire" and "Water"? I tried changing

    color="Type"


    but this results in an error

    Invalid element(s) received for the 'color' property of parcoords.line
    Invalid elements include: ['FIRE', 'FIRE', 'FIRE', 'FIRE', 'FIRE', 'WATER', 'WATER', 'WATER', 'WATER', 'FIRE']


    Thank you!

    Continue reading...

Compartilhe esta Página