【发布时间】:2020-04-15 23:57:44
【问题描述】:
我有一个由三组节点组成的图表 1. 服务器 2. 站 3. 用户 我想用网络内置的可视化来绘制它们。在图中,我想要用户和站的标签,而不是服务器的标签。但是,这不起作用。当我尝试这个时:
nx.draw_networkx_nodes(network,
with_labels=False,
nodelist=self.servers_idx,
node_size=50, node_shape='s',
pos=servers_pos,
node_color='r')
nx.draw_networkx_nodes(network, with_labels=True,
nodelist=self.stations_idx,
node_size=50, node_shape='^',
pos=stations_pos,
node_color='g')
nx.draw_networkx_nodes(network, with_labels=True,
nodelist=self.users_idx,
node_size=10, node_shape='o',
pos=users_pos,
node_color='b')
我得到下图:
如您所见,没有显示任何标签,但我已将工作站和用户的 with_labels 变量值设置为 True,并且期望它会显示它们。奇怪的是,当我将所有with_labels 设置为True 时,它会显示所有标签。但是,如果我只将其中一个设置为False,它将不会显示另外两个(就像我已将它们全部设置为 False)。有谁知道这里发生了什么?
【问题讨论】:
-
这看起来很像一个错误,我会在他们的 github 上提出一个问题,包括一些示例数据。
标签: python python-3.x matplotlib networkx