Arun Taneja
Arun Taneja

Reputation: 17

How to change width of line using a list of weigths in network graph

I am trying to change line width in 3d network graph plot. I am using igraph python library.I have different weights of edges. but i am not able to use those weights to change width of line representing the edge.Please help me with this.Following is the example code

eG=ig.Graph(directed=False)
eG.add_vertices(6)
eG.add_edges([(0,1),(1,2),(2,3),(3,4),(3,5),(5,3)])
eG.es['weight']=[12,1,2,3,4,1]

then i am trying to use these weigths for line width.Xe,Ye and Ze are also list and its working but line width is not working

trace1=Scatter3d(x=Xe,
           y=Ye,
           z=Ze,
           mode='lines',
            line=Line(color='rgb(125,125,125)',width =eG.es['weight']),
           hoverinfo='none'
           )

Upvotes: 0

Views: 746

Answers (1)

seralouk
seralouk

Reputation: 33147

I would use igraph's functions for plotting. It is easy to define the edge widths.

Example:

import igraph as ig

eG=ig.Graph(directed=False)
eG.add_vertices(6)
eG.add_edges([(0,1),(1,2),(2,3),(3,4),(3,5),(5,3)])
eG.es['weight']=[12,1,2,3,4,1]

layout = eG.layout("kk")

visual_style = {}
visual_style["vertex_size"] = 20
visual_style["vertex_label"] = eG.vs["name"]
visual_style["edge_width"] = eG.es['weight']
visual_style["bbox"] = (300, 300)

ig.plot(eG, **visual_style)

Results:

enter image description here

Upvotes: 1

Related Questions