wiheto / netplotbrain

A package to create simple 3D network visualizations on a brain.
Apache License 2.0
69 stars 7 forks source link

Issue with colouring edges by weight #63

Closed edhutch1 closed 4 months ago

edhutch1 commented 1 year ago

Hello,

I'd like to visualise a weighted network (weight varies from 0-1) by colour. With the following code:

netplotbrain.plot( template=template nodes=nodes edges=data_array, edge_cmap='viridis', edge_colorvminvmax=[0,1])

I get a network with only black edges. Please let me know what I'm doing wrong! Thanks very much for your time.

wiheto commented 1 year ago

Hi!

Let me look into that. I think it could be the case that this feature has never been implemented yet.

I'll get back to you within a day (with either a fix or an update implementing this).

wiheto commented 1 year ago

Ok I looked up the problem. I think the following should work

netplotbrain.plot( template=template nodes=nodes edges=data_array, edge_cmap='viridis', edge_colorvminvmax=[0,1], edge_color='weight')

The final argument is needed because netplotbrain needs to know you want the weights of the edges. Since you are supplying a connectivity matrix as the edge input, this should be obvious but needs to be explicitly stated (I'll look up trying to make this automatic in the future).

Let me know if that worked.

edhutch1 commented 1 year ago

It worked excellently! Thank you very much for your help.

edhutch1 commented 1 year ago

Another quick question - is there a simple way to display a colour bar within the figure legend?

wiheto commented 1 year ago

The legend at the moment is only really for nodes. It is something that should be added but just nobody has asked for it yet to get legend for edge weights and edge colours. Give me a week and I can add it.