xgi
xgi copied to clipboard
Add lattice layouts for plotting
Add an easy way to plot grid, triangular, and other regular lattices with a natural layout.
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.
You mean to attach the coordinates to each node as a node attribute?
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
And once the lattice is generated, there's a special plotting function that looks at the node attributes?
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.
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.