xgi-org / xgi

CompleX Group Interactions (XGI) is a Python package for higher-order networks.
https://xgi.readthedocs.io
Other
180 stars 28 forks source link

Warning when specifying node colors #499

Closed nwlandry closed 7 months ago

nwlandry commented 10 months ago

A minimal working example is

import xgi
import random

H = xgi.Hypergraph([[1, 2], [2, 3, 4]])

c1 = "maroon"
c2 = "white"
node_fc = [c1 if random.random() < 0.5 else c2 for i in H.nodes]
xgi.draw(H, node_fc=node_fc)

produces this warning

UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  node_collection = ax.scatter(
maximelucas commented 10 months ago

Yes, this is kind of matplotlib behavior I think. The default cmap is not None but you're specificying colors with colors and not with values so it's just saying there's no values to map to colors so cmap is ignored. We could fix this either by making sure cmap is None in case colors are specified, or by just hiding the user warning. In any case, the outputs are not wrong.

Liyubov commented 8 months ago

~~it is not directly related to the node color, but more node size and node labels, in the current https://xgi.readthedocs.io/en/stable/api/drawing/xgi.drawing.draw.html#module-xgi.drawing.draw it seems not clear to me if you also allow to specify the changed size of the text of node lables. and if yes, to document it on the drawing function maybe? thanks!~~

Edit by @maximelucas : created a new issue https://github.com/xgi-org/xgi/issues/500 with this because it's different enough