Matplotlib "pick_event" not working in embedded graph with FigureCanvasTkAgg
<p>I'm trying to handle some events to perform user interactions with embedded subplots into a Tkinter frame. Like in this <a href="http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html" rel="nofollow">example</a></p>

<p>Works fine with "key_press_event" and "button_press_event", but does not work with "pick_event".</p>

<p>I modified that example from the link, just adding the following piece of code after the <code>mpl_connect</code> calling:</p>

<pre><code>def on_button_press(event):
    print('you pressed mouse button')

canvas.mpl_connect('button_press_event', on_button_press)

def on_pick(event):
    print('you picked:',event.artist)

canvas.mpl_connect('pick_event', on_pick)
</code></pre>

<p>Why "pick_event" doesn't work into embedded graphs? And how do get it to work?</p>

<p>My configurations detailed:</p>

<ul>
<li>Windows 10</li>
<li>Python 3.5 (conda version)</li>
<li>Matplotlib 1.5.3 installed via pip</li>
</ul>

<p>Thanks in advance!</p>

<p>Well, I solved it...</p>

<p>Most events we just need to use <code>mpl_connect</code> method to the magic happen. My mistake is that I didn't notice that we need to say explictly that our plot is "pickable" putting a argument <code>picker=True</code> to only triggers the event if clicked exacly into the artist, and <code>picker=x</code> where <code>x</code> is an integer that is the pixel tolerance for the trigger. So beyond the changes I inserted for pick in the question, we should replace</p>

<p><code>a.plot(t, s)</code> for <code>a.plot(t, s,picker=True)</code> or <code>a.plot(t, s,picker=10)</code>, e.g.</p>

python events matplotlib tkinter