我想使用Python的Multinetx来绘制这个网络。这是我的命令:
import Multinetx as mx
import matplotlib.pyplot as plt
mg = mx.MultilayerGraph(list_of_layers=[mst_pearson,mst_kendall,mst_tail])
plt.axis('off')
pos = mx.get_position(mg,mx.fruchterman_reingold_layout(mst_pearson),
layer_vertical_shift=0.2,
layer_horizontal_shift=0.0,
proj_angle=47)
mx.draw_networkx(mg,pos=pos,node_size=50,with_labels=False,
edge_color=[mg[a][b]['weight'] for a,b in mg.edges()],
edge_cmap=plt.cm.jet_r)
plt.show()
mst_pearson,mst_kendall,mst_tail是我原来的网络,我想用它们来建立一个三层多层网络。但错误是:
KeyError Traceback (most recent call last)
<ipython-input-9-560c2e877b57> in <module>()
4 layer_vertical_shift=0.2,
5 layer_horizontal_shift=0.0,
----> 6 proj_angle=50)
7 mx.draw_networkx(mg,pos=pos,node_size=50,with_labels=False,
8 edge_color=[mg[a][b]['weight'] for a,b in mg.edges()],
C:\Users\wenzh\multinetx\draw.py in get_position(G, base_pos,
layer_vertical_shift, layer_horizontal_shift, proj_angle)
70
71 for j in range(N):
---> 72 pos[j][0] *= math.cos(proj_angle)
73 pos[j][1] *= math.sin(proj_angle)
74
KeyError: 0
这个错误是什么意思?我怎么能解决它?