我尝试生成一个图的子图的图像,其中节点应该出现在两个图的相同位置。在
基于documentation for networkx.draw the "pos" argumentto,draw函数接受指定节点位置的字典。我看到了几个例子,人们使用与此模式类似的pos参数:
positions = networkx.spring_layout( GraphObject )
networkx.draw( GraphObject, positions )
然而,当我尝试这样做时,我发现位置显然被忽略了——或者至少当我绘制一个图并记录其节点的位置,然后使用字典作为绘制子图的pos参数时,相应的节点并没有在相同的位置绘制。在
这是一个简单的复制机,演示了这个问题。我认为这段代码应该创建两个.png文件,包含两个图形“g”和“h”。节点“c”和“d”在“h”的绘图中应该与它们在“g”中的位置相同-但是它们不是。在
^{pr2}$有谁能建议我做错了什么,或者如何生成子图的图像,这些子图的节点与整个图的节点位于同一位置?在
以tcaswell的建议为出发点,我发现这对我很有用:
问题不在于
networkx
行为不当,而是这两幅图中的x和y极限不同相关问题 更多 >
编程相关推荐