Treemap continuous color based on variable

Hi! First time posting here.

I’m trying to create a treemap with plotly. I can’t find how to add a continuous color scale based on a variable different from the value used to create the treemap.

I’m trying to graph a CPI basket. So i have different subgroups and weights for each group and subgroup and the respective inflation per group. I would like to have as values the weights so I can have a notion of how big a group is, but also I would like the color be defined by the inflation value per group.

So far the colors correspond to the values, but not to the column I’m trying to reference it to.

fig <- plot_ly(
        type="treemap",
        labels= df$Categoría,
        parents=df$parent,
        values=df$w,
        textinfo="color+percent parent+percent entry",
        branchvalues='total',
        color=df$yoy,
        
)
fig

output:

As you can see from the picture the colorbar at the right corresponds to the values of the column YoY, but the color in the graph corresponds to the value column. Any help or guidance will be greatly appreciated.

1 Like

Having the same issue. I wish there was an option for the color argument that would specify to add the children of each parent instead of using the average of all the children to set the color on the color scale. Seems like an easy enough feature to implement. Unfortunately I think we are stuck with how this works under the hood.