import plotly.express as px
import pandas as pd
data = [['x' , 'S11' , '023' , 2.743 , 201],
['x' , 'S13', '302' , 0.448 , 55],
['x' , 'S12' , '023' , 3.575 , 389],
['x' , 'S15' , '023' , 0.329 , 378],
['x' , 'S1' , '023' , 0.627 ,167 ],
['x' , 'S1' , '302' , 0.177 , 7],
['x' , 'S1' , '304' , 0.314 , 16],
['x' , 'S3' , '302' , 1.474 , 24 ],
['x' , 'S3', '305' , 0.327 ,40 ],
['x' , 'S3', '308' , 0.211 , 25 ],
['x' , 'S3' , 'e18' , 0.035 , 1 ],
['x' , 'S4' , '023' , 0.032 , 62 ],
['x' , 'S4' , '036 ' , 0.048 , 5 ],
['x' , 'S4' , '201 ' , 0.221 , 600 ],
['x' , 'S4' , '302' , 0.106 , 65 ],
['x' , 'S4' , '305' , 0.011 , 1],
['x' , 'S4' , '307' , 0.068 , 90],
['x' , 'S4', '308' , 0.200 , 70],
['y' , 'B1' , '103 ' , 4.118 ,310 ],
['y' , 'B2' , '302' , 2.802 , 6],
['y' , 'B2' , 'l08' , 0.369 ,130 ],
['y' , 'B2' , 'l60 ' , 0.103 , 56],
['y' , 'B3' , '023' , 0.054 , 90],
['y' , 'B3' , '302' , 0.075 , 25],
['y' , 'B3' , '303' , 0.456 , 34],
['y' , 'B3' , '331 ' , 0.522 , 18],
['y' , 'B3' , 'l05 ' , 0.230 , 25],
['y' , 'B3', 'l08' , 0.008 , 1],
['y' , 'B5' , 'l08' , 1.098 , 418],
['y' , 'B5' , 'l09 ' , 0.425 , 24],
['y' , 'B5' , 'l24 ' , 0.214 , 38],
['y' , 'B6' , '304' , 0.395 , 40],
['y' , 'B6' , 'l08' , 1.252 ,309],
['y' , 'B7' , '023' , 2.343 , 295],
['y' , 'B8' , 'l08' , 0.055 , 37],
['y' , 'B8' , 'l09' , 0.045 , 7]
]
df = pd.DataFrame(data, columns=['A', 'B' ,'C', 'D', 'E'])
acolor_map = {'x': '#00285F', 'y': '#00A6EB'}
custom_text =df.groupby(['C', 'B', 'A'])['E'].sum().tolist() + df.groupby(['B', 'A'])['E'].sum().tolist() + df.groupby('A')['E'].sum().tolist()
print(df.groupby(['B', 'A'])['E'].sum().tolist() )
print(custom_text)
sunb = px.sunburst(df, path=['A', 'B', 'C'], values='D', color = 'A', color_discrete_map=acolor_map)
sunb.update_traces(hovertemplate='%{label}-D: %{value:.2f}h<br>E: %{hovertext}',
hovertext=custom_text)
sunb.show()
If you remove both color properties it works as intended. I often look at the segment B1 and 103 where both should be equal