Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

Plotly sunburst change the color based on two variables

Hello, everyone. I am working on a sunburst graph and figured out how to map the color based on one column thanks to the nice manual.
However, I failed to figure out how to change the color of the ‘parent’ part in my case.

Below is the code I used for the plot. Here I was able to set the ‘outcome’ column mapped to the color I wanted. But I was stuck by changing the color of z_score < -0,52 (red, e.g. ‘#ed2939’) and z_score >= -0,52 (blue, e.g. ‘#57d9d4’ ). At some point, plotly randomly assigned me red and blue, but it mapped totally in the opposite. I am looking forward to your suggestions and thank you.

Code for the plot:

outcome = ['wheeze_outcome 0','wheeze_outcome 1', 'wheeze_outcome 2','asthma', 'wheeze_outcome 0',
          'wheeze_outcome 1', 'wheeze_outcome 2','asthma']
zscore = ['z_score >= -0,52','z_score >= -0,52','z_score >= -0,52','z_score >= -0,52',
         'z_score < -0,52','z_score < -0,52','z_score < -0,52','z_score < -0,52']
values = [33,22,27,75,18,4,33,111]

df = pd.DataFrame(
    dict(outcome = outcome, zscore = zscore,values=values)
)
print(df)

df['zscore'] = df['zscore'].astype('category')
df['zscore'].cat.reorder_categories([ 'z_score < -0,52', 'z_score >= -0,52'], inplace = True)
fig = px.sunburst(df, path=['zscore','outcome'], values='values', color = 'outcome', 
                                   color_discrete_map = {'wheeze_outcome 0': '#4beb7e',
                                       'wheeze_outcome 1': 'grey',
                                       'wheeze_outcome 2': '#b810c7',
                                       'asthma': '#ed2939',
                                        #'(?)': ['#57d9d4','#ed2939']
                                        '(?)':'white'
                                       #'(?)':'#000000',
                                       
                                       })

fig.update_traces 
fig.show()

image
The plot I had, in which the color of z_score < -0,52 and z_score >= -0,52 should be in the way around.