[Python] Networkx: arrows, ploting

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    I need to change the default arrow style for digraphs on networkx. I've read something about matplotlib.patches.ArrowStyle, but I am too new coding and even newer in python, so I did not understand at all. My current code is:

    G=nx.DiGraph()
    n=len(C)
    print(n)
    for i in range(n):
    G.add_node(i)

    for i in nodos_usuarios:
    for j in nodos_cri:
    if Y[i,j].x==1:
    G.add_edge(i,j)

    pos = nx.circular_layout(G)
    x=G.node()
    y=G.edges()
    elist = edges
    print(x)
    print("")
    print(y)
    print("")
    nx.draw_networkx_nodes(G, pos, label="ciudades",size=0.1)
    nx.draw_networkx_labels(G, pos)
    nx.draw_networkx_edges(G, pos, edgelist=elist, edge_color='green', width=3, label="S")
    plt.legend(fontsize = 'medium')
    plt.axes().set_aspect('equal')
    plt.savefig("Red.png")
    plt.show()


    Y is a matrix related to the graph G. My current output is: Ugly graph - Ugly arrow

    So I need help to change this arrow style to the classical arrow that we all know. Is there someone could help me to do this more easily?

    Continue reading...

Compartilhe esta Página