python - Is there a way to add arrows for nx. draw in networkx? -
i using networkx in python , using nx.draw function takes in arrows=true parameter, arrows don't seem show up. when doing this, using g=nx.graph(), when use g = nx.digraph(), arrows show up, default network shape lost. there way preserve default network layout comes nx.draw , have arrows?
yes, have fix positions yourself, see below example using circular_layout
.
import networkx nx import matplotlib.pyplot plt g = nx.erdos_renyi_graph(20, 0.2) pos = nx.circular_layout(g) nx.draw_networkx(g, pos=pos) plt.show()
pos
dictionary nodes keys , coordinates values. plot digraph (with same node set):
g1 = nx.digraph(g) nx.draw_networkx(g1, pos=pos) plt.show()
Comments
Post a Comment