Line breaks for sankey labels

Hello! I have long labels for my sankey nodes, and Iā€™d like to break the content down to two lines:

What I have now:
ā€˜example label for sankey nodeā€™

What I want:
ā€˜example label
for sankey nodeā€™

Does anyone know if this is possible? I have tried a whole manner of packages and workarounds (
\n textwrap) etc. and nothing seems to work. Thanks in advance!

Add ā€œ<br>ā€ between the strings for each value. For example:

ā€œexample label for Sankey nodeā€ -> ā€œexample label <br> for Sankey nodeā€.

If you have your data in a df, then something like:
df[ā€˜labelā€™] = df[ā€˜pt1ā€™] + ā€˜<br>ā€™ + df[ā€˜pt2ā€™]

Hi louis,

Thanks for the input ā€“ unfortunately, I already tried that option and it doesnā€™t work. < br > just shows up as part of the text. I wonder if itā€™s specific to the internal formatting of sankey labelsā€¦

I donā€™t know whether it makes a difference, but Iā€™m also using f strings as part of the string Iā€™d like to break into two lines.

You mind sharing your code?

Sure, hereā€™s what Iā€™m working with:

node = dict(
label = [fā€™BAU Coal: {round(future_em_list[0]+avoided_em_list[0],2)}MMt CO2eqā€™]

I want ā€˜BAU Coal:ā€™ to be on one line and the rest to appear below.

So I tried a bunch of stuff, and it seems as tho the hover label does in fact work with the
added in, but the labels themselves donā€™t.
48%20PM

After some digging it seems like this is an issue that has been created:

https://github.com/plotly/plotly.py/issues/1499

Looks like itā€™s an issue on their side. I would recommend you add a shortened label and ad the full label on the hover (even though not ideal).

Thanks a bunch; thatā€™s what Iā€™ll do!