我试着用全息视图和博克做和弦图。我可以完成第一步,as explained here;但是,我不能创建组,也不能显示颜色和标签。 首先,我的数据*chord=*:
[['GK', 'WD ', 2],
['GK', 'C ', 1],
['GD', 'GK ', 1],
['GD', 'C ', 2],
['GD', 'WA ', 4],
['WD', 'GD ', 4],
['WD', 'C ', 1],
['WD', 'WA ', 2],
['WD', 'GA ', 1],
['C', 'GD ', 1],
['C', 'WD ', 1],
['C', 'WA ', 3],
['C', 'GA ', 2],
['C', 'GS ', 10],
['WA', 'C ', 2],
['WA', 'GA ', 9],
['WA', 'GS ', 7],
['GA', 'C ', 3],
['GA', 'WA ', 4],
['GA', 'GS ', 5],
['GS', 'C ', 6],
['GS', 'WA ', 1]]
值为[源、目标、值]。 让我陷入困境的是和弦图不会自动对源进行分组,如果我使用Sankey图表,就会发生这种情况。 因此,我创建我的组和标签:
^{pr2}$然而,结果远未达到预期:
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh')
%output size=200
chords = pd.DataFrame(chord, columns=['source','target','value'])
%opts Chord [label_index='source' color_index='target' edge_color_index='source']
%opts Chord (cmap='Category20' edge_cmap='Category20')
hv.Chord(chords)
如果我通过了
hv.Chord(chords, nodes)
我有个错误:
AttributeError: 'DataFrame' object has no attribute 'ndims'
谢谢你的帮助!在
如果您想将},例如:
nodes
传递给hv.Chord()
,那么请记住,您应该首先为nodes
调用{nodes = hv.Dataset(nodes_df, 'index')
,其中nodes_df
是熊猫的数据帧。在接下来: ^{cd7}
相关问题 更多 >
编程相关推荐