1 year ago

#345694

test-img

Redox

Holoviews Sankey graph labels not set when nodes are more than edges

I am using a python dataframe to collect data required for my Holoviews Sankey before creating the graph. I need specific labels for the nodes. The below works fine (as long as the number of edges >= number of nodes)

import pandas as pd

import holoviews as hv

from holoviews import opts, dim

hv.extension('bokeh')

data={'Start':['A','A','B','B'],'End':['X','Y','X','Y'],'Size':[3, 10, 6, 1],'Label': ['myA','myB','myX','myY']}

dfTesting=pd.DataFrame(data)

sankey = hv.Sankey(dfTesting).opts(show_values=False, labels=dim('Label'))

sankey.opts(width=600, height=400)

Sankey Graph created

However, if the edges < number of nodes, this will not work. Can you pls help on how to fix this? I need to use bokeh as I need the features in it and need custom labels as these are created dynamically based on user inputs. The below code gives as error as the plot is looking for the third label. Thank you.

data={'Start':['A','A'],'End':['X','Y'],'Size':[3, 10],'Label':['myA','myX']}  # no 'myY'

dfTesting=pd.DataFrame(data)

sankey = hv.Sankey(dfTesting).opts(show_values=False, labels=dim('Label'))

sankey.opts(width=600, height=400)

**ERROR ** - IndexError: index 2 is out of bounds for axis 0 with size 2

python

visualization

bokeh

sankey-diagram

holoviews

0 Answers

Your Answer

Accepted video resources