问题描述
我想用 networkx
渲染一个 matplotlib
图。标签有点长(每个大约 10 - 50 个字符),而且它们往往会被切断,使我无法阅读它们。有没有办法让 matplotlib “缩小”最终渲染,以便我可以阅读所有文本?
下面是我的代码以及渲染图。
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
root_node = 'this is the root node'
G.add_node(root_node)
for other_node in [
'test is an adjacent node','test is another adjacent node','test is yet another adjacent node','test is the fourth adjacent node',]:
G.add_node(other_node)
G.add_edge(root_node,other_node)
nx.draw(G,with_labels=True,font_size=8,node_color='white')
plt.show()