I tried the holoviews example for creating a chord diagram here which works fine. However when trying to modify the chord diagram, I have never been able to to get the edges to have the same color as the nodes, color-grouped by their respective group.
The modified code I use:
import pandas as pd
import holoviews as hv
from holoviews import opts, dim
from bokeh.sampledata.les_mis import data
hv.extension('bokeh')
hv.output(size=200)
links = pd.DataFrame(data['links'])
nodes = hv.Dataset(pd.DataFrame(data['nodes']), 'index')
chord = hv.Chord((links, nodes)).select(value=(5, None))
chord.opts(opts.Chord(labels='name',
cmap='Category20',
edge_cmap='Category20',
edge_color=dim('group').str(),
node_color=dim('group').str()))
The Data:
print(links.head(3))
nodes.data.head()
The Result:
Expected Result: The edges should have same color as the nodes.
A similar question for a different problem has been asked here, but no answers/solutions yet.
Any helps / suggestions are appreciated!
The
edge_color
andnode_color
parameters should not be the same. This should work:I think
node_color=dim('name').str()))
could also benode_color=dim('index').str()))
.