Skip to content
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

rescale_sizes doesn't work for numerical inputs #527

Open
nwlandry opened this issue Apr 2, 2024 · 3 comments
Open

rescale_sizes doesn't work for numerical inputs #527

nwlandry opened this issue Apr 2, 2024 · 3 comments
Labels
improve Make an existing feature better

Comments

@nwlandry
Copy link
Collaborator

nwlandry commented Apr 2, 2024

Minimal working example:

import xgi
H = xgi.Hypergraph([[1, 2, 3]])
nodal_property = [-1, 0, 1]
xgi.draw(H, node_size=nodal_property, rescale_sizes=True)

gives the error ValueError: node_size cannot contain negative values. We should make this consistent with how xgi handles nodestats, i.e., interpolating them between max and min values.

@maximelucas
Copy link
Collaborator

Do you mean that you would like the -1 to be rescaled to a positive value?
I feel like any negative value for a node size is wrong and should raise an error rather than be rescaled, but happy to be convinced.

@nwlandry
Copy link
Collaborator Author

nwlandry commented Apr 9, 2024

Maybe a work-around solution would be to publish a recipe detailing how to take a list of nodal values (In my case, continuous values between -1 and 1) and mapping them to node sizes. I probably would do something like

import xgi
import numpy as np
min_node_size = 1
max_node_size = 30

H = xgi.Hypergraph([[1, 2, 3]])
props = np.random.uniform(-1, 1, H.num_nodes)
node_size = np.interp(props, [props.min(), props.max()], [min_node_size, max_node_size])
xgi.draw(H, node_size=node_size)

@maximelucas
Copy link
Collaborator

Yea we can probably do that. My feeling is that I would probably rather visualize that by having colored nodes with a diverging colormap to visualize positive and negative values. What's your exact use case? An interpolation recipe is useful in any case I would say.

@maximelucas maximelucas added the improve Make an existing feature better label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve Make an existing feature better
Projects
None yet
Development

No branches or pull requests

2 participants