简体   繁体   English

Networkx:使图表更具可读性

[英]Networkx : Make a graph more readable

Good afternoon.下午好。

I'm on a shortest path finder with A* project, and for that I took some osm data with osmnx.我正在使用 A* 项目进行最短路径查找,为此我使用 osmnx 获取了一些 osm 数据。 When I want to plot my graph, I don't manage to print something good, even with changing the k parameter of spring_layout.当我想 plot 我的图表时,我无法打印出好的东西,即使更改了 spring_layout 的 k 参数。 Also, I would like to print my nodes labels, and my edges labels without printing the tuple {"weight", label}.另外,我想打印我的节点标签和边缘标签而不打印元组 {“weight”,label}。 I honestly didn't found how to make the whole thing clearer...老实说,我没有找到如何使整个事情更清楚...

Do you have any idea?你有什么主意吗?

if __name__ == '__main__':
    Data = open('edgelist_bruxelles.csv', "r")
    Graphtype = nx.MultiDiGraph()

    G = nx.parse_edgelist(Data, delimiter=',', create_using=Graphtype,
                          nodetype=int, data=(('weight', float),))
    
    pos = nx.spring_layout(G, 10)
    
    nx.draw_networkx_nodes(G, pos, node_size=50)
    nx.draw_networkx_edge_labels(G, pos, font_size=5)
    nx.draw_networkx_edges(G, pos, edge_color='r', arrows=True)
    mp.show()

What I have now我现在拥有的

1

Here are some things you could consider:以下是您可以考虑的一些事项:

  1. Add a title, perhaps some labels explaining what the nodes and vertices represent.添加一个标题,也许是一些标签来解释节点和顶点代表什么。
  2. Determine what you want to show about the data.确定要显示的有关数据的内容。 Currently, it is difficult to draw conclusions beyond 'many relationships'.目前,很难得出“许多关系”之外的结论。 If there is a particular path that you'd like to highlight, an approach could be to only display a smaller subset of the relationships or nodes.如果您想突出显示某个特定路径,一种方法可能是仅显示关系或节点的较小子集。
  3. You could also use color coding or something of the like to make things stand out more.您还可以使用颜色编码或类似的东西使事情更加突出。 For example, create a colormap for the different vertex values and see if anything stands out.例如,为不同的顶点值创建一个颜色图,看看是否有什么突出的。
  4. Removes nodes or order them deliberately to create less of a spiderweb.删除节点或故意对它们进行排序以减少蜘蛛网。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM