Hi all, I have an issue with go.Treemap
that I think is related to go.Treemap not rendering - Python.
Here’s a minimal working example:
I have 4 parents (i don’t know their value a priori) so I set it to zero. Each parent has 2 children.
import plotly.graph_objects as go
# Define the data structure
labels = [
# Parent nodes
"Parent A",
"Parent B",
"Parent C",
"Parent D",
# Children for Parent A
"Child A1",
"Child A2",
# Children for Parent B
"Child B1",
"Child B2",
# Children for Parent C
"Child C1",
"Child C2",
# Children for Parent D
"Child D1",
"Child D2",
]
parents = [
# Parents (root level)
"",
"",
"",
"",
# Children's parents
"Parent A",
"Parent A",
"Parent B",
"Parent B",
"Parent C",
"Parent C",
"Parent D",
"Parent D",
]
# Values for each node
values = [
# Parent values (will be ignored when using branchvalues="total")
0,
0,
0,
0,
# Children values
50,
100,
75,
25,
40,
60,
30,
70,
]
fig = go.Figure(
go.Treemap(
labels=labels,
parents=parents,
values=values,
branchvalues="total",
)
)
fig.show()
This doesn’t render at all and I believe this is due to branchvalues="total",
.
Now if I set `branchvalues=“remainder” I get:
Which looks right, but the displayed hovervalue is 0 for the parents.
While I guess this may be the expected behaviour, I would like to know if there is a way to not have to pre-calculate the value of the parents. I tried setting it as None
but that as well simply doesn’t render.
This sort of thing works perfectly with plotly express Treemap, but I would like to be able to use this more generic version to avoid having to use rectangular dataframes.
Thanks in advance!