OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get color from category in Plotly Coordinates Plot

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

Guest
I have a dataframe that looks like this: enter image description here

I want to crate a Coordinates Plot:

Code:
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: enter image description here

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

Code:
color="Type"

but this results in an error

Code:
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!
<p>I have a dataframe that looks like this:
<a href="https://i.sstatic.net/RdWQL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RdWQL.png" alt="enter image description here" /></a></p>
<p>I want to crate a Coordinates Plot:</p>
<pre><code>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()
</code></pre>
<p>And the result looks like this:
<a href="https://i.sstatic.net/3j2kG.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3j2kG.jpg" alt="enter image description here" /></a></p>
<p>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</p>
<pre><code>color="Type"
</code></pre>
<p>but this results in an error</p>
<pre><code>Invalid element(s) received for the 'color' property of parcoords.line
Invalid elements include: ['FIRE', 'FIRE', 'FIRE', 'FIRE', 'FIRE', 'WATER', 'WATER', 'WATER', 'WATER', 'FIRE']
</code></pre>
<p>Thank you!</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top