繁体   English   中英

使用Bokeh在网络图中拖放节点

[英]Drag & drop Nodes in network graph with Bokeh

我从Bokeh开始。 我绘制了一个网络图。 有用。 我想拖放节点以将它们移动到绘图中,以便更好地清晰节点关系:

到目前为止,我有以下内容(只写了重要的部分):

df = pd.read_csv('data.csv', sep=" ", header=None)
G = nx.from_pandas_edgelist(d, 0, 1) 
plot = Plot(background_fill_color="lightgrey",
        plot_width=800, plot_height=600,
        x_range=Range1d(-0.5, 0.5), y_range=Range1d(-0.5, 0.5))
graph_renderer = from_networkx(
    G, nx.spring_layout, scale=1, center=(0, 0))
# here is the issue:
plot.add_tools(PointDrawTool(
    renderers=[graph_renderer], empty_value='black'))
plot.renderers.append(graph_renderer)
...

PointDrawTool是支持拖放的工具。 以下文档说它需要一个渲染器(我假设: graph_renderer )但是我得到错误AttributeError: 'GraphRenderer' object has no attribute 'glyph'

一些指导意见。

更换时,Bokeh v1.1.0中的一切正常

plot.add_tools(PointDrawTool(renderers = [graph_renderer], empty_value='black'))

有:

plot.add_tools(PointDrawTool(renderers = [graph_renderer.node_renderer], empty_value = 'black'))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM