xgi icon indicating copy to clipboard operation
xgi copied to clipboard

Add lattice layouts for plotting

Open maximelucas opened this issue 2 years ago • 7 comments

Add an easy way to plot grid, triangular, and other regular lattices with a natural layout.

maximelucas avatar Sep 27 '22 10:09 maximelucas

I think the way to do this is rather to have generators of lattice models that also output the positions of the nodes. Those positions can then be passed to any drawing function. I would close this an open another issue to suggest implementing lattice generators.

maximelucas avatar Mar 27 '23 14:03 maximelucas

You mean to attach the coordinates to each node as a node attribute?

leotrs avatar Mar 27 '23 14:03 leotrs

Exactly. For example networkx has a with_positions argument: nx.triangular_lattice_graph(m, n, with_positions=True) https://networkx.org/documentation/stable/reference/generated/networkx.generators.lattice.triangular_lattice_graph.html

maximelucas avatar Mar 27 '23 15:03 maximelucas

And once the lattice is generated, there's a special plotting function that looks at the node attributes?

leotrs avatar Mar 27 '23 15:03 leotrs

Networkx does not have one, as far as I know. So you need to manually collect all the positions, and pass them to the draw function with the pos argument. But I agree we could have "lattice draw" functions that do that automatically, or a helper function that collects the positions from node attribute in a format that fits the pos argument.

maximelucas avatar Mar 27 '23 15:03 maximelucas

Alternatively, we could have a pos argument that works much like edge_fc et al in draw_xgi_simplices, that is, it could take a dict, a NodeStat, etc. This could be useful for plotting in general, not only for lattice networks.

leotrs avatar Mar 28 '23 06:03 leotrs