graspologic icon indicating copy to clipboard operation
graspologic copied to clipboard

New legend for `heatmap` in unweighted case

Open loftusa opened this issue 4 years ago • 10 comments

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

Screen Shot 2020-11-23 at 1 15 50 PM

loftusa avatar Nov 23 '20 18:11 loftusa

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.

bdpedigo avatar Nov 23 '20 18:11 bdpedigo

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?

bdpedigo avatar Nov 23 '20 18:11 bdpedigo

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

loftusa avatar Nov 23 '20 18:11 loftusa

I have code that looks like this

Screen Shot 2021-03-08 at 9 20 16 PM

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

loftusa avatar Mar 09 '21 03:03 loftusa

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?

bdpedigo avatar Mar 09 '21 03:03 bdpedigo

"edge/no edge".

what do you mean by this?

loftusa avatar Mar 09 '21 16:03 loftusa

instead of 0 / 1

bdpedigo avatar Mar 09 '21 17:03 bdpedigo

I gotta admit I had no idea what you were saying. I think you're saying the labels on the right, right?

daxpryce avatar Mar 09 '21 17:03 daxpryce

yes

bdpedigo avatar Mar 09 '21 17:03 bdpedigo

https://www.youtube.com/watch?v=VvPaEsuz-tY ;D

daxpryce avatar Mar 09 '21 17:03 daxpryce