擅长:python、mysql、java
<p>我不是这方面的专家,但是这里的代码使用了<code>pydot</code>库及其<code>graph_viz</code>依赖关系。这些库随Anaconda Python一起提供,但默认情况下不会安装,因此首先从命令提示符执行以下操作:</p>
<pre><code>conda install pydot
</code></pre>
<p>下面是改编自<a href="https://networkx.github.io/documentation/stable/auto_examples/drawing/plot_circular_tree.html#sphx-glr-auto-examples-drawing-plot-circular-tree-py" rel="nofollow noreferrer">Circular Tree</a>的代码。在</p>
^{pr2}$
<p>如果将窗口调整为方形,则结果是</p>
<p><a href="https://i.stack.imgur.com/eDvxt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eDvxt.png" alt="enter image description here"/></a></p>
<p>或者,如果您喜欢自顶向下的树,您可以将代码中的字符串<code>"twopi"</code>替换为<code>"dot"</code>,如果您使生成的窗口变宽,您将得到</p>
<p><a href="https://i.stack.imgur.com/FcJAe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FcJAe.png" alt="enter image description here"/></a></p>
<p>另外,如果使用字符串<code>"circo"</code>,并使窗口变宽,则可以得到</p>
<p><a href="https://i.stack.imgur.com/gJPfN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gJPfN.png" alt="enter image description here"/></a></p>