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.

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

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!