Open basselhak opened 6 years ago
Could it have something to do with this being a bipartite network, and so some of the nodes do not figure in the 'ORGANIZATION' or 'COUNTRY' dictionaries?
Potentially. I'm looking at the error trace, and seeing that the key MEP
is the source of the error. I think that should be a node.
Can I just check, does every node have an ORGANIZATION
and COUNTRY
associated with it?
No, only nodes in one bipartite set have an ORGANIZATION and COUNTRY association. I just now gave the nodes in the other bipartite set a 'null' value for these keys, and that seems to have fixed the problem.
Okay, got it. This does raise the question of whether nxviz
should auto-fill a "null" value for nodes that don't have a key. I'm hesitant to do so because it very likely means modifying the underlying graph data, which might have unintended consequences for a user. At the moment, it probably makes most sense to document for the end-user that all keys must be present on each node. I think I will create a separate "todo" issue regarding this.
Btw, just wanted to comment, this kind of feedback is the best for improving the library - thanks for taking the time to raise these issues!
Description
nxviz gives me a KeyError when attempting to set node orders and colors according to some of my node attributes. It works for the bipartite and centrality measures, but not for other attributes I've stored (like 'ORGANIZATION' or 'COUNTRY'), although I've confirmed that all these attributes are stored in the same way.
The 'ORGANIZATION' or 'COUNTRY' dictionaries contain strings with the names of countries or organizations of people in the dataset. I wonder if the error is caused by nxviz not being able to read strings as compared to the integers and floats in the centrality dictionaries.
@ericmjl speculated that the reason could be the number of variables exceeding the number of available colors in the colormap. But setting color according to a centrality measure seems to correctly produce a color map with a scale corresponding to measures: nxviz visualization with node color set according to a centrality measure
What I Did