✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Plotly sunburst node colors

Hi,

I have drawn a sunburst plot and it’s working fine except for color of nodes.
I am expecting the color of node to be mean of its children’s. But I am getting it as sum.

Here’s the code. Anything I am doing wrong?

fig = px.sunburst(ttt, path=['Industry','Symbol'], values='value', 
                  color = 'value',
                  color_continuous_scale=["red", "green"], range_color=[0.95,1.05]
                 )
fig.update_layout(title_text = returnType, width = 1000, height = 850)
fig.show()

Hi @kausti, thanks for the report, this looks like a bug. If you use a different column for values and for color it works fine ie the color corresponds to the average of the children. So as a workaround you can add a new column as in the code below. I opened https://github.com/plotly/plotly.py/issues/2567 to track the problem

import plotly.express as px
import numpy as np
df = px.data.gapminder().query("year == 2007")
df['copy_lifeExp'] = df['lifeExp']
fig = px.sunburst(df, path=['continent', 'country'], values='copy_lifeExp',
                  color='lifeExp',
                  color_continuous_scale='RdBu')
fig.show()

Thanks @Emmanuelle for quick response.
Your work around does the job.

Cheers