How to configure the plotly tree graph to calculate the sum and not the mean?

Asked

Viewed 11 times

0

The official description says about this graphic : " If a color argument is passed, the color of a Node is computed as the Average of the color values of its Children, Weighted by their values." That is, the color is being defined by the average of 'Childrens'. But I need it to be defined by the sum of 'Childrens'. I looked everywhere, and as I found nothing, I’m thinking that there is no such option. But at the same time it seems intuitive that it should exist ...

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

I also accept indication of alternatives. I am losing hope with plotly. All I need is a tree chart with two types of indicators : Color and size. Like that of plotly.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.