I am plotting directed graph using networkx in python. However, I found that arrow head of edge is thick from one end instead of pointed arrow. I want to change the thick edge to pointed arrow. Here is my code, actual output, and desired output:
import networkx as nx
import matplotlib.pyplot as plt
G=nx.DiGraph()
item = [1,2]
G.add_edge(*item) #color = item[-1], weight = 2)
pos = nx.circular_layout(G)
nx.draw(G, pos, with_labels = True, edge_color = 'b')
plt.show()
Output
Desired output:
Any suggestion would be really helpful?
This may be a late answer, but in the new version networkx 2.1 you can set the arrow type by using the arrowstyle and arrowsize parameter.
import networkx as nx
import matplotlib.pyplot as plt
G=nx.DiGraph()
item = [1,2]
G.add_edge(*item) #color = item[-1], weight = 2)
pos = nx.circular_layout(G)
nx.draw(G, pos, with_labels = True, edge_color = 'b', arrowsize=20, arrowstyle='fancy')
plt.show()
You can go to the documentation for details: https://networkx.github.io/documentation/stable/reference/generated/networkx.drawing.nx_pylab.draw_networkx_edges.html#networkx.drawing.nx_pylab.draw_networkx_edges
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With