Closed galenseilis closed 2 years ago
Thank you for raising this issue; for general information on draw
, please refer to the documentation and Tutorial 2 - Visualization Methods.
There are several methods for customizing the layout of a hypergraph when using draw
. From the documentation:
The default
layout
algorithm isnx.spring_layout
, but other layouts can be passed in. The Hypergraph is converted to a bipartite graph, and the layout algorithm is passed the bipartite graph. If you have a pre-determined layout, you can pass in apos
dictionary. This is a dictionary mapping from node id’s to x-y coordinates. For example:pos = { 'A': (0, 0), 'B': (1, 2), 'C': (5, -3) }
will position the nodes {A, B, C} manually at the locations specified. The coordinate system is in Matplotlib “data coordinates”, and the figure will be centered within the figure.
For small layout adjustments on simple hypergraphs like the one in your example, I recommend doing something like this:
# get the positions for the default layout
pos = hnx.draw(H, return_pos=True)
# for the sake of this example, assume that the original position of the fst_score node is (1,1)
# we want to move it up and to the right, so increase the value of both coordinates
pos['fst_score'] = (2,2)
# redraw the hypergraph using the updated custom layout
hnx.draw(H, pos=pos)
You may need to play around a bit with the updated custom coordinates to achieve your desired layout. Feel free to follow up with specifics/code for your example if you'd like additional support!
I made the following diagram using Hypernetworkx's
draw
command.The node
fst_score
node appears really close to the233
hyperedge, making it hard to distinguish whether the node is a member of the hyperedge. Is there a setting an argument somewhere that would allow me to ensure that the hyperedges maintain a minimal distance from the nodes?