Search code examples
pythonplotlysunburst-diagramiciclesicicle-diagram

How to show multiline text in a plotly icicle?


I have a plotly icicle object named fig: fig = px.icicle(df, names="people"...).

I want to show more text than just df.people. I tried the following:

fig.update_traces(texttemplate=df.people + "\n" + "more text, but on a new line")

But this does not produce a new line and instead prints a tab.


Solution

  • fig.update_traces(texttemplate='%{label}<br>%{customdata["more_text"]}')
    fig.update_traces(customdata=df['more_text'])