Sankey diagram with percentages

I’ve created a Sankey diagram, which presents alright, but it would be much more useful if it displayed percentages alongside (or instead) the raw values for each flow (e.g. if my base node sums to 100, and each flow’s value is 20, to also present 20% on each flow’s hover).

Is there a way to do that?

Below is my plotting code:

data = dict(
        type='sankey',
        node = dict(
          pad = 20,
          thickness = 20,
          line = dict(
            color = "black",
            width = 0.25
          ),
          label = label_list
        ),
        link = dict(
          source = df['sourceID'],
          target = df['targetID'],
          value = df['count']
        )
      )
    
    layout =  dict(
        title = title,
        font = dict(
          size = 15
        )
    )
       
    fig = dict(data=[data], layout=layout)
    pio.show(fig)

Same question actually, I think somehow we should use the “meta” or “customdata” keys in “hovertemplate” but I can’t understand how and there is no example of how to do that.

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online