我使用matplotlib来显示数字,但是当涉及到最后一个数字时,它不显示它的内容(只是创建窗口)。 我用它来描述图的最大独立集。所以,sets实际上是一个包含节点列表的列表。Matplotlib不显示最后的数字
pos=nx.spring_layout(G) # positions for all nodes
for i in range(0, len(sets)):
nx.draw_networkx_nodes(G,pos, sets[i],
node_color='r', node_size=500, alpha=0.8)
rest = []
for j in nodes:
if j not in sets[i]:
rest.append(j)
nx.draw_networkx_nodes(G,pos, rest,
node_color='w', node_size=500, alpha=0.8)
nx.draw_networkx_edges(G,pos,width=1.0,alpha=0.5)
plt.axis('off')
plt.figure(i)
plt.show()
如果将'plt.show()'移动到循环中,您是否仍然看到相同的内容? –
它有一个非常奇怪的行为。它显示了每个循环的两个窗口,其中一个是空的,另一个是正确的。另一个问题是,它等待我关闭他们,然后继续并显示下一个 –