Currently, plotly express treemap shows only label inside treemap. How to include the value alongside the label?
That's why I don't like express, there are too many limitations and to make these kinds of changes you have to access the trace either way. From my point of view it is better and more code-transparent to use plain plotly instead.
That being said, you can access the textinfo
attribute of the trace to do this. From the reference:
Determines which trace information appear on the graph.
Any combination of
"label"
,"text"
,"value"
,"current path"
,"percent root"
,"percent entry"
,"percent parent"
joined with a"+"
OR"none"
.
Taking an example from the site:
df = px.data.tips()
fig = px.treemap(df, path=['day', 'time', 'sex'], values='total_bill')
# this is what I don't like, accessing traces like this
fig.data[0].textinfo = 'label+text+value+current path'
fig.layout.hovermode = False
fig.show()
Also take a look at the texttemplate
attribute for formatting options.