graspologic
graspologic copied to clipboard
New legend for `heatmap` in unweighted case
Right now, when we use heatmap
in the unweighted case, the legend shows up as a gradient. It would be better if it showed up as two distinct colors, since our matrix is binary.
see my beautiful photoshopped image below
did you mean heatmap instead of pairplot and unweighted instead of undirected? if so, I usually just omit the colorbar entirely when plotting binary. it is a bit of an overreach to tell the user their data is binary and force a new colormap on them - for instance there are some cases where edges can be in {0, 1} but the didn't have to be if that makes sense. that being said, im not super opposed since this comes up a lot for me but my default would be to just remove the colorbar.
also the only way I see to robustly check this is all_the_same_thing(A[A != 0])
and not sure how expensive that is?
did you mean heatmap instead of pairplot and unweighted instead of undirected?
yes, changed
if so, I usually just omit the colorbar entirely when plotting binary. it is a bit of an overreach to tell the user their data is binary and force a new colormap on them - for instance there are some cases where edges can be in {0, 1} but the didn't have to be if that makes sense.
good point
also the only way I see to robustly check this is all_the_same_thing(A[A != 0]) and not sure how expensive that is?
there's an is_unweighted
function in utils
that returns ((A == 0) | (A == 1)).all()
, not sure how computationally expensive that is either
I have code that looks like this

could add something like a binary_cbar
parameter on heatmap
if we wanted.
I'm fine adding it, or not, just depends on whether there's interest from other people
happy to have if you find useful, maybe would recommend it being smaller, and possibly something like "edge/no edge".
for now I'd just say let's keep it as an option and not check for this automatically?
"edge/no edge".
what do you mean by this?
instead of 0 / 1
I gotta admit I had no idea what you were saying. I think you're saying the labels on the right, right?
yes
https://www.youtube.com/watch?v=VvPaEsuz-tY ;D