question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assign colors to arrows in network graphs

See original GitHub issue

Hi @marcomusy

This is a follow up to my previous post here https://github.com/marcomusy/vedo/issues/182#issuecomment-667694798

I could color the edges based on edge weights

edg.cellColors(vals, cmap='viridis', vmin=vmin, vmax=vmax)  #Blues_r
        edg.addScalarBar3D(
            title=' title',
            titleFont='VictorMono',
            labelFont='VictorMono',
            c='k',
            # titleXOffset=-1.5,
            # titleYOffset=0
        )
        
arrsv=[]
for i, j in G.edges():
    dv = nodes[j]-nodes[i]
    cn = (nodes[j]+nodes[i]) /2
    v = dv/mag(dv)*1.5
    ar = Arrow(cn-v, cn+v, s=.02, c='k')
    arrsv.append(ar)

show(pts, graph, labs1, labs2, arrsv)

This assigns colors to the edges and the arrows are colored black. Instead, I’d like to assign colors to arrows (something like arrsv.cellColors inplace of edg.cellColors/ cmap) instead of edges and also generate scalarbar for the colors assigned to the arrows (e.g. arrsv.addScalarBar3D() ).

Could you please offer suggestions on how to do this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
marcomusycommented, Dec 26, 2020

E.g.

from vedo import *
lut = buildLUT([
          (10, 'dg',),
          (40, 'red'),
      ],
          vmin=10, vmax=40,
          interpolate=False,
          aboveColor='yellow',
      )

rgb = [0,0,0]
lut.GetColor(58, rgb)
print(getColorName(rgb))

yellow

1reaction
marcomusycommented, Dec 25, 2020

Just specify the color right after the cmap:

# manually build a lookup table for mapping colors
settings.defaultFont = 'VictorMono'  # set this as default if you like it, so it'll be used for axes too
edg.cmap('viridis', weights, on='cells').c('grey')

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visualizing Networks - Kelsey Andersen
Here, for example, we color the nodes and change the size and position of the labels using vertex.color = and vertex.label.dist = plot(mat3,...
Read more >
How to Specify Arrowhead Color - Mathematica Stack Exchange
I've written this code and would like to color just the arrowheads (say) red. It would also be nice to select specific arrowheads...
Read more >
Network visualization with R
The major ones are color, size, shape, and position. Network visualization controls. Honorable mention: arrows (direction) and labels (identification).
Read more >
7 Network Visualization and Aesthetics - Bookdown
First, we can change the color, size, shapes and labels of nodes. Second, we can change the color, width, curviture and appearance of...
Read more >
Unexpected arrow color behavior with semi-transparent edges ...
color is specified as rgb() with option alpha < 1 , the arrows become differentially colored.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found