Color nodes by Networkx node attribute with Bokeh

时光怂恿深爱的人放手 提交于 2019-12-04 17:13:31

The question is a little vague, so I am not sure the code below is exactly what you are asking for. (Is the "node" attribute what you copy in to the "names" column? I think so...) But regardless, you can use linear_cmap to colormap the fill_color according to any CDS column:

from bokeh.transform import linear_cmap
graph.node_renderer.glyph = Circle(
    size=10, 
    fill_color=linear_cmap('name', 'Spectral8', min(G.nodes()), max(G.nodes()))
)

Alternatively if the column is string factors, you could also use factor_cmap.

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