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()Actual output:Desired output
Any suggestion would be really appreciated. Thanks
### Added by Satyam Mukherjee
if G.is_directed() and arrows:
edge_collection = LineCollection(edge_pos,
colors = edge_colors,
linewidths = lw,
antialiaseds = (1,),
linestyle = style,
transOffset = ax.transData,
)
edge_collection.set_alpha(alpha)
#else:
arrows=[]
for src,dst in edge_pos:
x1,y1=src
x2,y2=dst
dx=x2-x1 # x offset
dy=y2-y1 # y offset
vu_x=dx/sqrt(dx*dx+dy*dy)#direction in arc sense
vu_y=dy/sqrt(dx*dx+dy*dy)
p=0.03
arrows.append(FancyArrow(x1,y1,dx-p*vu_x,dy-p*vu_y,head_width=p,length_includes_head=True,).get_verts())
#arrows.append(Arrow(x1,y1,dx,dy, width=lw,length_includes_head=True,).get_verts())
arrow_collection = PolyCollection(arrows,
facecolors = edge_colors,
antialiaseds = (1,),
transOffset = ax.transData,
linewidths = lw,
linestyle = style,
)
# update view
xx= [x for (x,y) in head+tail]
yy= [y for (x,y) in head+tail]
minx = amin(xx)
maxx = amax(xx)
miny = amin(yy)
maxy = amax(yy)
w = maxx-minx
h = maxy-miny
padx, pady = 0.05*w, 0.05*h
corners = (minx-padx, miny-pady), (maxx+padx, maxy+pady)
ax.update_datalim( corners)
ax.autoscale_view()
edge_collection.set_zorder(1) # edges go behind nodes
ax.add_collection(edge_collection)
## Added by Satyam Mukherjee
if arrow_collection:
arrow_collection.set_zorder(1) # edges go behind nodes
ax.add_collection(arrow_collection)
return edge_collection
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to networkx-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/networkx-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to networkx-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/networkx-discuss.
For more options, visit https://groups.google.com/d/optout.