def drawRoads(G, edgeColorAttribute='level', edgeColorScale=9, nodeColorAttribute=None, nodeColorScale=None):
pos={}
for n in G.nodes():
pos[n] = (G.node[n]['longitude'],G.node[n]['latitude'])
# nodes
nx.draw_networkx_nodes(G,pos,node_size=0,alpha=0.8,color=colors[-1])
# edges
for i in range(0,9):
selectedEdges = [(u,v) for (u,v,d) in G.edges(data=True) if d['level'] == i]
selectedColors = [colors[i] for e in selectedEdges]
nx.draw_networkx_edges(G,pos,edgelist=selectedEdges,width=edgeWidth[i],edge_color=selectedColors)
plt.show()
评论列表
文章目录