网络x中的draw_networkx()
我在尝试 networkx 时收到此错误
networkx.draw_networkx(G,ax = self.axes)
TypeError: draw_networkx() takes at least 2 non-keyword arguments (1 given)
相同的代码是
G=networkx.Graph()
G.add_node("spam")
G.add_edge(1,2)
networkx.draw_networkx(G,ax = self.axes)
有人可以解释我做错了什么以及如何纠正这个错误.... 该函数的链接是 draw_networkx 。
谢谢
I am getting this error when trying networkx
networkx.draw_networkx(G,ax = self.axes)
TypeError: draw_networkx() takes at least 2 non-keyword arguments (1 given)
The code for the same is
G=networkx.Graph()
G.add_node("spam")
G.add_edge(1,2)
networkx.draw_networkx(G,ax = self.axes)
Can someone explain what am I doing wrong and how can I correct this....
The link for the function is draw_networkx.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它需要 pos 参数来通知绘图例程如何定位节点。以下是如何使用 spring 布局填充
pos
:输出:
It is expecting the
pos
argument, to inform the drawing routine how to position the nodes. Here's how you can use a spring layout to populatepos
:Output:
样本偏差给出了一个很好的例子。
如果您想要一种更简单的方法来进行命令行分析或搞乱:
这是一种基于弹簧重量和荣誉重量的内置绘图方法,因此您可以包括以下内容:
并且 1-2 连接将比1-垃圾邮件连接由于弹簧加权。非常快速和容易。
samplebias gave a great example.
If you want an even simpler way to do it for command line analysis or messing around:
It's a built in method for drawing based on spring weights and honors weights so you can include stuff like:
And the 1-2 connection will be shorter than the 1-spam connection due to spring weighting. Very quick and easy.