将信息从绘图传递到函数
Pass info from plot to function
我想使用图形工具编写交互式模拟。我想做的是首先将图形可视化,然后选择节点作为稍后实际模拟的输入。如何将信息从绘图传递到函数?
到目前为止我做了什么 - 我查看了没有提供此类信息的文档和示例。
谢谢!
如果您调用 graph_draw
并将 output
参数设置为 None
(默认设置),它 returns a:
Boolean-valued vertex property map marking the vertices which were
selected interactively.
如果未给出 output
,图表“将通过 interactive_window()
" whose documentation points to GraphWidget
显示键绑定信息:
A group of vertices may be selected by holding the “shift” button
while the pointer is dragged while pressing the left button.
例如:
import numpy as np
import graph_tool.all as gt
points = np.random.random((25, 2))
g, pos = gt.geometric_graph(points, 0.3)
_, selected = gt.graph_draw(g, pos=pos)
print(*selected.a)
输出:
1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0
我想使用图形工具编写交互式模拟。我想做的是首先将图形可视化,然后选择节点作为稍后实际模拟的输入。如何将信息从绘图传递到函数?
到目前为止我做了什么 - 我查看了没有提供此类信息的文档和示例。
谢谢!
如果您调用 graph_draw
并将 output
参数设置为 None
(默认设置),它 returns a:
Boolean-valued vertex property map marking the vertices which were selected interactively.
如果未给出 output
,图表“将通过 interactive_window()
" whose documentation points to GraphWidget
显示键绑定信息:
A group of vertices may be selected by holding the “shift” button while the pointer is dragged while pressing the left button.
例如:
import numpy as np
import graph_tool.all as gt
points = np.random.random((25, 2))
g, pos = gt.geometric_graph(points, 0.3)
_, selected = gt.graph_draw(g, pos=pos)
print(*selected.a)
输出:
1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0