How to put the legend value into the square in a Plotly Treemap

43 Views Asked by At

I'd like to add the legend's value into of each square in the plotly Treemap, as a label. Also, is it possible to make the legend start from 0 instead of negative numbers?

Here's my code:

fig = px.treemap(df_plataforma_uf_vl_ofertado_ex_0, path=[px.Constant("Valor disputado em milhões R$ e taxa de conversão em %"), 'nm_plataforma', 'cd_estado'], values=round((df_plataforma_uf_vl_ofertado_ex_0['vl_total_ofertado']/1000000),2),
                  color='tx_conversao_%', hover_data=['tx_conversao_%'],
                  color_continuous_scale='RdBu',
                  color_continuous_midpoint=np.average(df_plataforma_uf_vl_ofertado_ex_0['tx_conversao_%'], weights=df_plataforma_uf_vl_ofertado_ex_0['vl_total_ofertado']))
fig.update_layout(margin = dict(t=50, l=50, r=25, b=25))
fig.data[0].textinfo = 'label+text+value'

And here is the Treemap:

Plotly Treemap

Thanks

0

There are 0 best solutions below