python 更改 Networkx 中的节点显示大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2383121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Node Display Size in Networkx
提问by inspectorG4dget
I am not using GraphViz because I am having problems with making it play nice with Networkx. I know this is weird, but I've tried many suggestions to fix this problem, but I just seem to have some of the worst luck in the world. Therefore the problem that I have must be solved withing Networkx without using GraphViz.
我没有使用 GraphViz,因为我在让它与 Networkx 配合使用时遇到了问题。我知道这很奇怪,但我已经尝试了很多建议来解决这个问题,但我似乎有一些世界上最糟糕的运气。因此,我必须在不使用 GraphViz 的情况下使用 Networkx 解决我的问题。
My program reads a document and and tries to draw something of a MindMap based on the contents of the document. However, Networkx seems to have a default size when it comes to actually drawing the node. This is bad for me because a lot of text goes into each of my nodes. I need a way to increase the display-size of my nodes (arbitrarily, based on the size of the text that belongs in that node).
我的程序读取一个文档并尝试根据文档的内容绘制一些思维导图。但是,在实际绘制节点时,Networkx 似乎具有默认大小。这对我来说很糟糕,因为我的每个节点都有很多文本。我需要一种方法来增加节点的显示大小(任意地,基于属于该节点的文本的大小)。
I have tried looking at the Networkx site, other questions on SO and about 200 search results from Google, with no luck.
我曾尝试查看 Networkx 站点、关于 SO 的其他问题以及来自 Google 的大约 200 个搜索结果,但没有运气。
回答by Nick
Try nx.draw(G, node_size=size
), where size
can be a scalar or an array of length equal to the number of nodes.
尝试nx.draw(G, node_size=size
),其中size
可以是标量或长度等于节点数的数组。