在 Python 中用交互式图形绘制算法
我想要可视化一种算法的效果,该算法采用 2d 向量作为输入,并提供 2d 向量数组作为输出(其中数组在索引 k 处具有第 k 次迭代值)。
我希望它的工作方式是在左侧绘制一定范围的数字的二维图来表示输入向量,并在右侧绘制一个类似的二维图来绘制连接的输出向量。
对于单个输入点,我知道我可以使用 matplotlib 的 plt.subplots() 来完成此操作,就像文档中松散改编的示例一样:
fig, axs = plt.subplots(2)
fig.suptitle('Vertically stacked subplots')
axs[0].plot(in_x, in_y)
axs[1].plot(out_array_x, out_array_y, 'o-')
但我想做的是移动输入侧的点使用鼠标并以交互方式获得右侧的结果输出。这怎么可能做到呢?
I want to visualise the effect of an algorithm that takes a 2d vector as input and delivers an array of 2d vectors as output (where the array has the k-th iteration value at index k).
The way I would like this to work is by having a 2d plot of a certain range of numbers on the left that represents the input vector, and a similar 2d plot on the right that plots the connected output vectors.
For an individual input point I know I could do this with matplotlib's plt.subplots()
like this loosely adapted example from the documentation:
fig, axs = plt.subplots(2)
fig.suptitle('Vertically stacked subplots')
axs[0].plot(in_x, in_y)
axs[1].plot(out_array_x, out_array_y, 'o-')
But what I would like to do is to move the point on the input side with the mouse and get the resulting output on the right interactively. How could this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论