当节点超过边缘时未设置的holoviews sankey图标签
在创建图表之前,我使用 python 数据框来收集 Holoviews Sankey 所需的数据。我需要节点的特定标签。下面的代码工作正常(只要边数 >= 节点数)
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)
但是,如果边 <节点数量,这将不起作用。您能帮忙解决这个问题吗?我需要使用散景,因为我需要其中的功能,并且需要自定义标签,因为这些标签是根据用户输入动态创建的。下面的代码给出了错误,因为绘图正在寻找第三个标签。谢谢。
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)
**错误 ** - IndexError:索引 2 超出尺寸 2 的轴 0 的范围
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)
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论