I am trying to get a treemap with plotly that shows the sum of two quantities on hovering (length and height) for each group
I can do that with one of them, but not with the other. What I have now is:
import pandas as pd
import plotly.express as px
data = {
"group": ["A", "A", "B", "B", "B", "C"],
"subgroup": ["A1", "A2", "B1", "B2", "B3", "C1"],
"lenght": [10, 11, 20, 21, 22, 30],
"height": [110, 111, 220, 221, 222, 330],
}
df = pd.DataFrame(data)
fig = px.treemap(
df,
path=[px.Constant("all"), "group", "subgroup"],
values="lenght",
hover_data=["lenght", "height"],
)
fig.update_traces(textinfo="value")
fig.show()
And the result of hovering is this one:
current state
I would like the question mark to be the sum of all children heights, How can this be achieved?