How to set node size and color in bokeh network graph?

会有一股神秘感。 提交于 2019-12-06 15:46:26

You are doing thins nearly right :)

Instead of manual list creation, you should create a data_source of renderer and use its name for automatic attribute selection (the other part of my code is in your another question):

gr = from_networkx(
    G,
    nx.circular_layout,
    scale=1,
    center=(0,0)
)
gr.node_renderer.data_source.data['index'] = list(reversed(range(len(G))))
gr.node_renderer.data_source.data['colors'] = Spectral8

gr.node_renderer.glyph = Circle(
    size='index',
    fill_color='colors'
)

will draw you:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!