CUSTOMDATA not annotating correct information

Hi all,

I am trying to use customdata to display more information as a text template on my treemap. Unfortunately, the text being displayed does not match my data. Below is an example using a simplified dataset:

Code for treemap:

Treemap:
image

Data:

In testing, I find that the year displays properly if added as another layer to the treemap, however I do not wish to display my data in this manner:

Updated code:

Updated map:
5

I have updated my plotly and python. Any ideas as to what I am doing incorrectly?

Hi @BBNR welcome to the forums.

Did you check for duplicates in your df? This sometimes leads to something similar.

Hi @AIMPED

Thanks for the reply, this issue has really been stumping me.

I tested it with a remove duplicates line but faced the same issue. In a subsequent test, I changed the β€˜Year’ column to have values 0 β†’ len(df) and noticed that the annotations appear to be linked to the wrong pathing. For example, here is my updated code:

(Note the altered year value post sorting: df[β€˜Year’] = (range(0, len(df))))

Which produces the following values:

However, my treemap looks like this:

Which is akin to the opposite pathing I have (TO 49ers instead of the desired FROM 49ers):

My original data has another layer, so doing something like flipping the From/To in the mapping won’t work. Any ideas?

Thank you again for all the help!

Just wanted to bump this, as I am still dealing with the issue. I can now confirm that swapping the from/to does showcase the correct information in the sample data, however I could not work this out in the main data that includes 3 layers instead of 2.

Am I missing something about the fundamentals of treemaps? Why are my text annotations incorrect?