【发布时间】:2021-07-22 17:17:18
【问题描述】:
matplotlib 文档中那个帖子的问题解决:https://matplotlib.org/stable/users/event_handling.html
【问题讨论】:
标签: python matplotlib onclick qt-designer
matplotlib 文档中那个帖子的问题解决:https://matplotlib.org/stable/users/event_handling.html
【问题讨论】:
标签: python matplotlib onclick qt-designer
第一个问题,你可以看看这个
Matplotlib Plot Points Over Time Where Old Points Fade
第二个,试试这样的
#list to store the points
points = []
#click event
def onclick(event):
global points
print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' %
(event.button, event.x, event.y, event.xdata, event.ydata))
#store the points in a list
points.append([event.x, event.y, event.xdata, event.ydata])
plt.plot(event.xdata, event.ydata, ',')
每次单击时,点集都会添加到点列表中。反之亦然,如果您想访问例如坐标,通过第三次点击存储,只需输入
print(f"x={points[2][0]}, y={points[2][1]}, xData={points[2][2]}, yData={points[2][3]}")
【讨论】: