Home > Enterprise >  Show data values in plotly icicle chart
Show data values in plotly icicle chart

Time:11-04

I want to show my value data within each box of my icicle chart, but the udpate_traces command I've used before for bar charts isn't working:

import plotly.express as px
# df is a pandas dataframe with columns level_1,2,3 and total
fig = px.icicle(df, path=['level_1', 'level_2', 'level_3'], values='total')
fig.update_traces(texttemplate="%{values:.1}")

This just prints out the text inside the "" in the icicle chart rather than the 'total' values to one decimal place. (Writing "%{total:.1}" does the same thing too.

Is there a way to display the values below the category label in a plotly icicle chart?

CodePudding user response:

texttemplate requires value (without 's'):

fig.update_traces(texttemplate="%{value:.1}")
  • Related