Plotting directed graphs in Python in a way that show all edges separately

前端 未结 4 1735
Happy的楠姐
Happy的楠姐 2020-12-01 04:44

I\'m using Python to simulate a process that takes place on directed graphs. I would like to produce an animation of this process.

The problem that I\'ve run into i

4条回答
  •  时光取名叫无心
    2020-12-01 05:22

    Maybe I am a little late but I found another solution to you issue, so I post it so that can be helpful if somebody has the same problem. This is adding the connectionstyle argument to nx.draw:

    import networkx as nx
    import matplotlib.pyplot as plt 
    
    G = nx.MultiDiGraph()
    
    G.add_edges_from([
        (1, 2),
        (2, 3),
        (3, 2),
        (2, 1),
    ])
    
    plt.figure(figsize=(8,8))
    nx.draw(G, connectionstyle='arc3, rad = 0.1',)
    

    Here you see the result:

    The result

提交回复
热议问题