I am trying to create a treemap. The dataframe df_all_trees has some more columns which I would like to display as information on hovering. How do I add this data into a variable that can be then used in hovertemplate?
Maybe you could also use px.treemap here, in which case you can pass the additional columns to the hover_data argument of px.treemap, and then they will be added automatically to the hovertemplate. See for example the example in https://plotly.com/python/plotly-express/
Hi @Emmanuelle thanks for your help. I was not able to get around the array stacking to get to my desired solution, however the px.treemap case worked well. Thank you very much.
In addition to this, would you be able to help me to disable hover text for hierarchies? I am trying to build a multi-level treemap and I do not want the hovertext to display for the hierarchies because the respective values would not be present. Eg. For stock market, I would have data for stock but not for itβs sector(eg. IT).
Hi @saboo.anuj17 if you want to remove information from the default hover, youβll need to modify the hovertemplate of the figure. You can do print(fig) to see the hovertemplate which is used in your current figure and modify it with fig.update_traces(hovertemplate=...).
Hi @Emmanuelle I realize this is an old conversation, but it has helped me along. I have one small follow-up question: is there a way to have the print(fig) output be more verbose? In my session, it is abridging with a ββ¦β string the section I am most interested in. :-/