TypeError: draw_networkx_labels() got an unexpected keyword argument "node_color"
TypeError: draw_networkx_labels() got an unexpected keyword argument "node_color"
我正在使用 networkx 包使用余弦相似度计算社区网络的频率计数,下面是我尝试绘制网络图的代码部分,但出现此错误。
S=nx.Graph() # draws the community detection graph
S.add_nodes_from(names)
S.add_weighted_edges_from(sim_edges)
pos1 = nx.spring_layout(S)
plt.figure(figsize=(10,10),dpi=200)
part = community_louvain.best_partition(S)
values = [part.get(node) for node in S.nodes()]
nx.draw_networkx_nodes(S,pos=pos1,node_color = values, node_size=8400, cmap =cmap1)
nx.draw_networkx_labels(S,pos=pos1,node_color = values, node_size=8400, font_size=10)
nx.draw_networkx_edges(S,pos=pos1, edgelist=edge_weights.keys(),width=list(edge_weights.values()))
plt.axis('off')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-ae3fd091a221> in <module>
47 values = [part.get(node) for node in S.nodes()] #get all names in network go to the partition get entry from the partitionget entry with node name - values is a list of entries that were the value in partition got by looking up each node name in network
48 nx.draw_networkx_nodes(S,pos=pos1,node_color = values, node_size=8400, cmap =cmap1) #colour nodes by which community they in
---> 49 nx.draw_networkx_labels(S,pos=pos1,node_color = values, node_size=8400, font_size=10)
50 nx.draw_networkx_edges(S,pos=pos1, edgelist=edge_weights.keys(),width=list(edge_weights.values())) #keys are the edges and weights are values -edge weight dcitionary get edges and values
51 plt.axis('off')
TypeError: draw_networkx_labels() got an unexpected keyword argument 'node_color'
来自网络X documentation on draw_networkx_labels
,
可用参数不包括 node_color
,如果您愿意,可以更改字体颜色及其透明度:
font_color (string) – Font color string (default=’k’ black)
alpha (float or None) – The text transparency (default=None)
我正在使用 networkx 包使用余弦相似度计算社区网络的频率计数,下面是我尝试绘制网络图的代码部分,但出现此错误。
S=nx.Graph() # draws the community detection graph
S.add_nodes_from(names)
S.add_weighted_edges_from(sim_edges)
pos1 = nx.spring_layout(S)
plt.figure(figsize=(10,10),dpi=200)
part = community_louvain.best_partition(S)
values = [part.get(node) for node in S.nodes()]
nx.draw_networkx_nodes(S,pos=pos1,node_color = values, node_size=8400, cmap =cmap1)
nx.draw_networkx_labels(S,pos=pos1,node_color = values, node_size=8400, font_size=10)
nx.draw_networkx_edges(S,pos=pos1, edgelist=edge_weights.keys(),width=list(edge_weights.values()))
plt.axis('off')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-ae3fd091a221> in <module>
47 values = [part.get(node) for node in S.nodes()] #get all names in network go to the partition get entry from the partitionget entry with node name - values is a list of entries that were the value in partition got by looking up each node name in network
48 nx.draw_networkx_nodes(S,pos=pos1,node_color = values, node_size=8400, cmap =cmap1) #colour nodes by which community they in
---> 49 nx.draw_networkx_labels(S,pos=pos1,node_color = values, node_size=8400, font_size=10)
50 nx.draw_networkx_edges(S,pos=pos1, edgelist=edge_weights.keys(),width=list(edge_weights.values())) #keys are the edges and weights are values -edge weight dcitionary get edges and values
51 plt.axis('off')
TypeError: draw_networkx_labels() got an unexpected keyword argument 'node_color'
来自网络X documentation on draw_networkx_labels
,
可用参数不包括 node_color
,如果您愿意,可以更改字体颜色及其透明度:
font_color (string) – Font color string (default=’k’ black)
alpha (float or None) – The text transparency (default=None)