在弹簧布局中更改节点的颜色+网络x
如何更改位置未知的颜色节点
所以我看到了这个 stackoverflow 上的链接,其中已给出明确设置的节点位置的答案。
但是假设我现在有一个像这样的图表
G = nx.Graph()
for i in range(10):
G.add_node(i)
for i in range(9):
G.add_edge(i,i+1)
pos = nx.spring_layout(G)
node_num = random.randint(0,10)
,但是如果我有一个随机数并将其着色为蓝色,让其他的为红色......我将如何使用 nodes_list
属性来实现它>'draw_networkx' 函数 它有整数节点。如果您能为任何类型的节点名称提供解决方案,那将会更有帮助......
非常感谢......
How can I change the nodes of a color where the location is not known
So i have seen this link on stackoverflow where the answer has been given for an explicitly set positions of nodes.
But say i have a graph like this
G = nx.Graph()
for i in range(10):
G.add_node(i)
for i in range(9):
G.add_edge(i,i+1)
pos = nx.spring_layout(G)
node_num = random.randint(0,10)
Now however if I have something as get a random number and color it blue and let others be red .... how would i implement it using nodes_list
attribute of 'draw_networkx'
function
This has nodes for integers. If you can give a solution for any type of node name it would be more helpful....
thanks a lot..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一些可能有帮助的代码。这会选择一个随机节点将其着色为蓝色,并将其余节点着色为红色。
Here is some code that might help. This choses a random node to color blue and colors the rest red.