def on_button(self, event):
# only consider events from the lines Axes
if event.inaxes is not self.ln.axes:
return
# if not the left mouse button or a modifier key
# is held down, bail
if event.button != 1 or event.key not in (None, 'shift'):
print('key+button: {!r}+{!r}'.format(event.key, event.button))
return
if event.key == 'shift':
# compute the distance to each point *in data space*
d = np.hypot(np.asarray(self.xdata) - event.xdata,
np.asarray(self.ydata) - event.ydata)
# find the closest point
ix = np.argmin(d)
# remove that data point
del self.xdata[ix]
del self.ydata[ix]
else:
# get the event location in data-space
# and add to internal data list
self.xdata.append(event.xdata)
self.ydata.append(event.ydata)
# update the line
self._update_line()
02-event_filter.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录