mnets / pymnet

The original library for analyzing multilayer networks.
https://mnets.github.io/pymnet/
GNU General Public License v3.0
118 stars 24 forks source link

Seeking help, encountered an error with fig = draw(),how to deal with it? #20

Closed Morri2676 closed 1 month ago

Morri2676 commented 8 months ago

AttributeError Traceback (most recent call last)

in () 23 two_layer_net[4, 4, 'a', 'b'] = 1 24 ---> 25 fig = draw(two_layer_net, layout="circular") ....... AttributeError: 'NoneType' object has no attribute 'text'
cloner174 commented 3 months ago

Hi, Why Are you using it like that? Considering how to import the library, you should do one of these:

import pymnet
# Create an instance of it :
two_layer_net = pymnet.MultilayerNetwork()
# For it to be a neet work : 
two_layer_net.add_layer('a')
two_layer_net.add_layer('b')
two_layer_net.add_node(4,'a')
two_layer_net.add_node(4, 'b')
# And then :
two_layer_net[4, 4, 'a', 'b'] = 1
pymnet.draw(two_layer_net , layout="circle", show = True )

OR

from pymnet import *
# Create an instance of it :
two_layer_net = MultilayerNetwork()
# For it to be a neet work : 
two_layer_net.add_layer('a')
two_layer_net.add_layer('b')
two_layer_net.add_node(4,'a')
two_layer_net.add_node(4, 'b')
# And then :
two_layer_net[4, 4, 'a', 'b'] = 1
draw(two_layer_net , layout="circle", show = True)

Be Aware: The option for layout is"circle" , Not 'circlar' !!!

ercco commented 1 month ago

Hi, it is not clear where the error is occurring. The error message shows that you're trying to call a method of a None object, which I couldn't replicate with the draw function. If you want to draw the network into a specific axes object, you can use the ax parameter of draw.