Plotly Express Treemap Apply Color Gradient to each Sub S`ection

Hello,

I’m currently building a treemap where I’d like to apply the color gradient I have to each sub group of the treemap, rather than the whole treemap itself. I’ve found no easy way to do this online (I’m using plotly express).

Here’s what the chart currently looks like. I’d essentially like to apply the color scale separately to Primary, General, … separately. Is that possible?

Here’s my current code:

tm = px.treemap(treemap_data,
                path=['Type', 'Contributor'],
                values='Count',
                color='Count',
                color_continuous_scale= px.colors.diverging.RdBu[::-1],
                height=800)
tm.data[0].textinfo = 'value'

Essentially, I’d like to apply the scale to each Type