<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="157397310" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/6497" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/6497/hovercard" href="https://github.com/matplotlib/matplotlib/pull/6497">#6497</a> (checked by bisection) let to pick events reporting incorrect events for step plots.</p>
<p dir="auto">MWE:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from pylab import *
plot(rand(100), picker=5, drawstyle=&quot;steps-pre&quot;)  # 5 points tolerance
def on_pick(event):
    print(event.ind)
cid = gcf().canvas.mpl_connect('pick_event', on_pick)
show()"><pre class="notranslate"><code class="notranslate">from pylab import *
plot(rand(100), picker=5, drawstyle="steps-pre")  # 5 points tolerance
def on_pick(event):
    print(event.ind)
cid = gcf().canvas.mpl_connect('pick_event', on_pick)
show()
</code></pre></div>
<p dir="auto">On 1.5.1, clicking on the "right" part of the plot reports an index close to 100 (that is, the number of points).  On master, the index is instead close to 200 (because each point is "duplicated" in the path).</p>
<p dir="auto">While the previous behavior could "easily" be restored, it may be a good time to revisit what the "index" returned by <code class="notranslate">Line2D.contains</code> actually means.  Specifically:</p>
<ul dir="auto">
<li>For non-step plots, I think the indices should actually be floats, that indicate where between which two points the projection of the click onto the line falls (for each line for which the projection is close enough), and how close to each extremity of the segment.  (This would be only a minor backwards incompatibility if the returned index is used, well, to index the data: recent numpys would emit a warning about indexing with a float.)</li>
<li>For step plots, it is less clear what the correct solution is.  Perhaps keeping the status quo and returning the index of the preceding point(s) would be enough.</li>
</ul>
<p dir="auto">The weekly build with nightly wheels from numpy and pandas<br>
has failed. Check the logs for any updates that need to be<br>
made in matplotlib.<br>
<a href="https://github.com/matplotlib/matplotlib/actions/runs/2175468878">https://github.com/matplotlib/matplotlib/actions/runs/2175468878</a></p>