Change node arrow type and size - Netwokx

1,725 views
Skip to first unread message

lint...@google.com

unread,
May 29, 2018, 5:10:54 AM5/29/18
to networkx-discuss
HI all, 
I am trying to use Networkx to draw a DAG on Colab and I have set the 'arrowstype' as '->', however, it always gives me a very thick arrow and part of arrow doesn't show (see the below fig). Below is my code, any suggestions on how to set the arrowtype and arrowsize?

Best,
Linting

# -----------code begin----------------------------
  G = nx.DiGraph(edges)
  pos = pos_nodes   # pos_nodes =  {'A':(0,0), 'B':(10,0), 'C':(20:0)..........}
  plt.figure(figsize=(0.8*len(nodes_on_path),0.5*len(nodes_on_path)))
  nx.draw_networkx_nodes(G, pos, node_color='skyblue', node_size=600)
  nx.draw_networkx_edges(G, pos, arrowstyle='->', arrowsize=10)
  nx.draw_networkx_labels(G, pos, labels, font_size=15, font_family='sans-serif')
  ax = plt.gca()
  ax.set_axis_off()
  plt.show()
  plt.close
# ----------code end----------------------------






Dan Schult

unread,
May 29, 2018, 5:28:50 AM5/29/18
to networkx...@googlegroups.com
There is a note in the docs for draw_networkx_edges() that says you should include the node_size argument that you used to draw the nodes. It then says that it uses that size to position the arrows.  That may be why your arrows partially don't show.

The arrowstyle may not show up well at the size you specify. Try 20 and it is more clear what the style is. When the size gets small the difference between styles is not very many pixels.

--
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.

Reply all
Reply to author
Forward
0 new messages