python - How to prevent overlap visualizing tree diagram with networkx and graphviz? - Stack Overflow

admin2025-04-18  5

Using networkx and graphviz, I am trying to visualize a tree with many nodes. No matter what parameters I use, I am unable to prevent the nodes from overlapping, which makes them illegible. Are there areguments/parameters I could use to fix this?

Below is the relevant section of my code and the resulting output:

rcParams['figure.figsize'] = 100, 100
pos = graphviz_layout(G, prog='dot', args='')


nx.draw(G,
        pos = pos,
        node_color='lightgreen', 
        node_shape="o",
        node_size=500,
        with_labels=True, 
        arrows=True,
        font_size=10)

plt.show()

转载请注明原文地址:http://anycun.com/QandA/1744929514a89629.html