pymnet icon indicating copy to clipboard operation
pymnet copied to clipboard

Plotting a six-layer multilayer

Open sofiabaur opened this issue 2 years ago • 2 comments

Hi, I'm trying to plot a multilayer with six layers, but I only get 3 and a half layers. I have tried modifying the figsize but the other layers are still blank, although the lab of those layers appears. I would appreciate your help to visualize the whole network.

Also, I would like to know how to set the order of layers.

Thanks for advance.

image

sofiabaur avatar Mar 15 '22 02:03 sofiabaur

I get the same issue with a 4 layer network, where only 3 layers are visible.

gorostiolam avatar Mar 01 '23 14:03 gorostiolam

Well this would be a little bit tricky ! But I will guide you as much as I able to.

First You need to import and Create an instance of Class :

from pymnet import MultilayerNetwork

And Add some layers and nodes and edges :

g = MultilayerNetwork(aspects=1) 

g.add_layer('A')
g.add_layer('B')
g.add_layer('C')
g.add_layer('D')
g.add_layer('F')
g.add_layer('G')


for i in range(3):
    g.add_node(node=i, layer='A')

for i in range(3, 6):
    g.add_node(node=i, layer='B')

for i in range(6, 9):
    g.add_node(node=i, layer='C')

for i in range(9, 12):
    g.add_node(node=i, layer='D')

for i in range(12, 15):
    g.add_node(node=i, layer='E')

for i in range(15, 18):
    g.add_node(node=i, layer='F')

for i in range(18, 21):
    g.add_node(node=i, layer='G')

g[1, 6, 'A', 'F'] = 1
g[1, 17, 'A', 'B'] = 1
g[14, 20, 'B', 'C'] = 1
g[4, 6, 'E', 'G'] = 1
g[19, 3, 'B', 'D'] = 1
g[9, 3, 'A', 'D'] = 1

Now, In term of visualization!

from pymnet import draw

For sake of solving this issue, you can adjust two parameters base on your prefers !

"layergag" -->> The space between the layers 
"camera_dist" -->> the distance between figure and the camera( Your sight )

Let us see how it is going to work,


# Option One :
draw(g, layergap=0.4, show = True)

# Option Two :
draw(g, camera_dist= 27, show = True)

# Or Combine these two, to have a more beautiful/customize  fig!
draw(g, layergap=0.6, camera_dist= 15, show = True)

cloner174 avatar Apr 23 '24 19:04 cloner174

Like @cloner174 said, fitting the layers into the figure depends on the distances between layers (the layergap parameter), among other things. You have to experiment with the draw parameters to get the layout you want. You can also adjust the elev parameter which changes the tilt angle of the layers to fit more layers in the figure.

ercco avatar Jun 17 '24 09:06 ercco