更改networkx-python中添加_节点的字体

更改networkx-python中添加_节点的字体,python,networkx,Python,Networkx,如何更改使用网络添加节点创建的节点的字体 代码: g=nx.Graph() g=nx.Graph() node=0 for i in range(len(newinput)): for j in range(0,len(newinput[i])): g.add_node(node,size=1,pos=(newinput[i][j][0],newinput[i][j][1])) node+=1 pos = nx.spring_layout(g)

如何更改使用网络添加节点创建的节点的字体

代码:

g=nx.Graph()
g=nx.Graph()
node=0
for i in range(len(newinput)):
    for j in range(0,len(newinput[i])):
        g.add_node(node,size=1,pos=(newinput[i][j][0],newinput[i][j][1]))
        node+=1

    pos = nx.spring_layout(g)
    pos = nx.get_node_attributes(g, 'pos')

conn=0
while conn<node-1:
    g.add_edge(conn, conn + 1)
    conn+=1
nx.draw(g,pos)
pylab.show()
g=nx.Graph()
node=0
for i in range(len(newinput)):
    for j in range(0,len(newinput[i])):
        g.add_node(node,size=1,pos=(newinput[i][j][0],newinput[i][j][1]))
        node+=1

    pos = nx.spring_layout(g)
    pos = nx.get_node_attributes(g, 'pos')

conn=0
while conn<node-1:
    g.add_edge(conn, conn + 1)
    conn+=1
nx.draw(g,pos,node_size=0.5)
pylab.show()
g=nx.Graph()
g=nx.Graph()
节点=0
对于范围内的i(len(newinput)):
对于范围(0,len)(新输入[i])中的j:
g、 添加_节点(节点,大小=1,位置=(newinput[i][j][0],newinput[i][j][1]))
节点+=1
位置=nx.弹簧布置图(g)
pos=nx.获取节点属性(g,'pos')
康涅狄格=0

而conn我可以通过draw函数中的node_size属性来解决这个问题

nx.绘图(g,位置,节点大小=0.5)

代码:

g=nx.Graph()
g=nx.Graph()
node=0
for i in range(len(newinput)):
    for j in range(0,len(newinput[i])):
        g.add_node(node,size=1,pos=(newinput[i][j][0],newinput[i][j][1]))
        node+=1

    pos = nx.spring_layout(g)
    pos = nx.get_node_attributes(g, 'pos')

conn=0
while conn<node-1:
    g.add_edge(conn, conn + 1)
    conn+=1
nx.draw(g,pos)
pylab.show()
g=nx.Graph()
node=0
for i in range(len(newinput)):
    for j in range(0,len(newinput[i])):
        g.add_node(node,size=1,pos=(newinput[i][j][0],newinput[i][j][1]))
        node+=1

    pos = nx.spring_layout(g)
    pos = nx.get_node_attributes(g, 'pos')

conn=0
while conn<node-1:
    g.add_edge(conn, conn + 1)
    conn+=1
nx.draw(g,pos,node_size=0.5)
pylab.show()
g=nx.Graph()
节点=0
对于范围内的i(len(newinput)):
对于范围(0,len)(新输入[i])中的j:
g、 添加_节点(节点,大小=1,位置=(newinput[i][j][0],newinput[i][j][1]))
节点+=1
位置=nx.弹簧布置图(g)
pos=nx.获取节点属性(g,'pos')
康涅狄格=0

而conn2问题:1)你能说明什么是
newinput
?使用代码处理数据也很方便(这样人们就不必自己生成数据)。2) 您是只想显示没有顶点的边,还是想用不同的形状和颜色绘制顶点?@Tuan333:newinput是具有x和y坐标的list[list[]。并希望仅显示带有节点的边。我可以这样做:)使用-
nx。draw(g,pos,node_size=0.5)
将其作为答案提交。谢谢你的帮助。