[BUG] `Networkplot` assumes `node_data` is integer 0...n-1 indexed
bdpedigo opened this issue · comments
Expected Behavior
Networkplot
should work with arbitrarily indexed node_data
Actual Behavior
Obscure error with matplotlib caused by incorrect series mapping for colors
What's going on
If you look at this line
https://github.com/microsoft/graspologic/blob/96d80b2261cff724bf0a082a249e60ee8ec1a878/graspologic/plot/plot.py#L1366
it is doing a map operation using plot_df[hue_key]
as the mapping. This is a pd.Series
, so the mapping is plot_df.index
-> elements of the series plot_df[hue_key]
. However, I passed in data where the index of the node data were names of neurons as opposed to an integer index that goes 0...n-1. This is implicitly what is being assumed here since at this point in the code, nodes in edgelist
are indexed numerically.
What to do
I think this can basically be resolved by doing plot_df = plot_df.reset_index()
, which assumes that plot_df
and adjacency
are positionally indexed, but we assume that already. also should add a test for this use case.
cc @dlee0156