'How do i colour Sunburst rings in Plotly based on different conditions
I am having trouble using plotly to colour certain data values in my sunburst visual. E.g. My data looks like the first code block below and i want my sunburst to colour the unknowns a certain colour e.g. black in my code. However, i can only pass through one argument using color=1. How can i pass in multiple values (so that i can color the unknowns in the different columns)?
6 5 4 3 2 1 weight
3 5 3 Unknown 10 11 1
3 5 3 Unknown 10 11 1
3 Unknown 3 Unknown 10 11 1
3 Unknown 3 Unknown 10 11 1
3 Unknown 3 Unknown 10 11 1
Unknown 5 3 Unknown 10 11 1
Unknown 5 3 Unknown 10 11 1
Unknown 5 3 Unknown 10 11 1
2 1 3 Unknown 10 11 1
2 1 3 Unknown 10 11 1
2 1 3 Unknown 10 11 1
My python code looks like the below.
import pandas as pd # import pandas
import plotly.express as px # import plotly package
df = pd.read_excel('data.xlsx',sheet_name="Sheet1")
fig = px.sunburst(df, width=500,height=500,path=[6,5,4,3,2,1], values='weight',color=1,color_discrete_map={'Unknown':'black'})
fig.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
