1

I was able to add some text in the inner squares of the plotly px.treemap with this answer. Basically using:

fig.data[0].customdata = whatever
fig.data[0].texttemplate = template whatever

However, I would like to add text also to outer squares, a littlebit like this image:

enter image description here

Is it possible to do that?

Derek O
  • 16,770
  • 4
  • 24
  • 43
J Agustin Barrachina
  • 3,501
  • 1
  • 32
  • 52
  • I have no experience with that customization. Does it serve your purpose to have a long string of labels from the beginning? `labels=['Some info
    Some more info
    bla bla', ...]`
    – r-beginners Jun 26 '23 at 09:34
  • Mhm `labels` parameter seems tempting. I tried but it does not work. So either I did not understand what it was or I am using it incorrectly. In any case, the description says it's a dictionary. Do you have an example of how it should work? – J Agustin Barrachina Jun 26 '23 at 11:54
  • In the example in this [reference](https://plotly.com/python/treemaps/#set-different-attributes-in-treemap), I tried the label in HTML format, like a comment. – r-beginners Jun 26 '23 at 12:48
  • Yes, indeed, it worked. It is a bit nasty because such a long name makes the text super small and in the end I cannot read it... But I guess it is a solution... If you elaborate I could mark as solution. Although if there is a way to keep values big it would be better. I also profitted I now use `go.Treemap` to use the `text` parameter which is more neat, but still it desapears if there are some 'sons' – J Agustin Barrachina Jun 26 '23 at 14:12

0 Answers0