Closed
Description
See joferkington/mpldatacursor#36.
Briefly, Line2D.contains
currently assumes that points in the line are connected by straight segments, thus ignoring drawstyle
. Minimal example (edited from the event handling doc):
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('click on points')
line, = ax.plot(np.random.rand(10), picker=5, drawstyle="steps-pre") # 5 points tolerance
def onpick(event):
thisline = event.artist
xdata = thisline.get_xdata()
ydata = thisline.get_ydata()
ind = event.ind
points = tuple(zip(xdata[ind], ydata[ind]))
print('onpick points:', points)
fig.canvas.mpl_connect('pick_event', onpick)
plt.show()
Clicking on the drawn line does not always trigger an event. Clicking on the not-drawn "straight" segments connecting the data points does.
Metadata
Metadata
Assignees
Labels
No labels