擅长:python、mysql、java
<p>可以使用以下方法设置单个节点位置,然后提取要在绘制时使用的“pos”字典。</p>
<pre><code>In [1]: import networkx as nx
In [2]: G=nx.Graph()
In [3]: G.add_node(1,pos=(1,1))
In [4]: G.add_node(2,pos=(2,2))
In [5]: G.add_edge(1,2)
In [6]: pos=nx.get_node_attributes(G,'pos')
In [7]: pos
Out[7]: {1: (1, 1), 2: (2, 2)}
In [8]: nx.draw(G,pos)
</code></pre>
<p><strong>更新</strong></p>
<p>添加绘图</p>
<p><a href="https://i.stack.imgur.com/MscDX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MscDX.png" alt="enter image description here"/></a></p>