-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
barycenter_spring_layout plots everything too close in the center not allowing a clear visualization #340
Comments
Hi @Mattehub! Thanks for your report. Could you please send us the edge list of this hypergraph so we can play around with it and see how best to help here? It would also help us if you could tell us the version of XGI you're using. Thanks! |
Hi @Mattehub ! I was not able to run the code you provided, but I think I have a version that may or may not be what you are looking for. Please see the code before, which I arrived at by modifying your code. While it's not the prettiest picture, I do not see the nodes clumping together in the middle. If this works for you, great! If it does not, would you be able to provide us with an image of your output that specifically shows what is the problem you are trying to fix? Thanks! import xgi
import numpy as np
import pickle
import operator
import matplotlib.cm as cm
# load data
with open('links_test', "rb") as f:
links = pickle.load(f)
# set random weights
zipped = zip(links, np.random.rand(len(links)))
zipped_ord = sorted(zipped, key = operator.itemgetter(1))
weights = [tuple(link) + (weig, ) for link, weig in zipped_ord]
# create Hypergraph
H_hypergraph = xgi.Hypergraph()
H_hypergraph.add_weighted_edges_from(weights)
# compute color of all edges
h1 = [h for _, h in zipped_ord]
cmap = cm.Reds((h1 - min(h1)) / max(h1 - min(h1)), alpha=0.1)
# plot!
xgi.draw(
H_hypergraph,
dyad_color='black',
dyad_lw=1.5,
edge_fc=cmap,
node_fc='white',
node_ec='grey',
node_lw=1,
node_size=10,
max_order=3,
node_labels=True,
hyperedge_labels=False,
) |
One more comment on this is that pos = xgi.pairwise_spring_layout(H_hypergraph)
xgi.draw(
H_hypergraph,
pos,
dyad_color='black',
dyad_lw=1.5,
edge_fc=cmap,
node_fc='white',
node_ec='grey',
node_lw=1,
node_size=10,
max_order=3,
node_labels=True,
hyperedge_labels=False,
) it looks a bit cleaner. |
Our spring layouts are based on networkx's, but networkx's have more parameters: like We could have more control by allowing these parameters to be passed to our functions too and then internally to networkx's. Two options:
What do you think? After deciding to implement this or nothing I think we can close the issue. |
I'd allow all of them. |
H_hypergraph
is a weighted hypergraph, with 9 nodes and only triangles. With this code I got a plot with all the nodes very close to each other in the center of the figure. Is there a way in which i can chose a minimum or average distance between nodes when using this layout?The text was updated successfully, but these errors were encountered: