paulbrodersen / netgraph

Publication-quality network visualisations in python
GNU General Public License v3.0
667 stars 40 forks source link

ArcDiagram throws warning, does not label nodes, does not preserve node order. #70

Closed jaredsagendorf closed 1 year ago

jaredsagendorf commented 1 year ago

A minimal example:

L = 8
nodes = list(range(L))
edges = [(0,5), (1,7), (2,5)]
g = nx.Graph()
g.add_nodes_from(nodes)
g.add_edges_from(edges)
ArcDiagram(g, node_size=1, node_color='k', node_edge_width=0.1, edge_alpha=1.0, edge_width=0.1, node_order=nodes, node_labels=True)
plt.show()

This should plot nodes from 0 to 7 in order from left to right and label them. However, it neither preserves the order of the nodes, or places labels and it throws the warning:

netgraph/_utils.py:360: RuntimeWarning: invalid value encountered in divide
  v = v / np.linalg.norm(v, axis=-1)[:, None] # unit vector
paulbrodersen commented 1 year ago

Hi, thanks for raising the issue.

ArcDiagram(g, node_size=1, node_color='white', node_edge_width=0.1, edge_alpha=1.0, edge_width=0.1, node_order=nodes, node_labels=True)

Figure_1

I will close the issue for now but feel free to re-open if any of these problems are not sufficiently addressed.

paulbrodersen commented 1 year ago

This issue should now be fixed on the dev branch, and will be available on the main branch / from PIPy / from conda-forge with the next major release (>5.0.0).