matplotlib multiple values under cursor
<p>This question is very similar to those answered here,</p>

<p><a href="http://stackoverflow.com/questions/14754931/matplotlib-values-under-cursor">matplotlib values under cursor</a></p>

<p><a href="http://stackoverflow.com/questions/14349289/in-a-matplotlib-figure-window-with-imshow-how-can-i-remove-hide-or-redefine">In a matplotlib figure window (with imshow), how can I remove, hide, or redefine the displayed position of the mouse?</a></p>

<p><a href="http://stackoverflow.com/questions/27704490/interactive-pixel-information-of-an-image-in-python">Interactive pixel information of an image in Python?</a></p>

<p>except that instead of pixel data (x,y,z) I have various measurements associated with (x,y) coordinates that I'd like to portray on a line plot. Specifically, the (x,y) are spatial positions (lat, lon) and at each (lat,lon) point there is a collection of data (speed, RPM, temp, etc.). I just sketched up something quickly to illustrate, a scatter plot with connecting lines, and then when you hover over a data point it displays all of the "z" values associated with that data point.</p>

<p>Is there an easy way to do something like this?</p>

<p><a href="http://i.stack.imgur.com/rJvn9.png" rel="nofollow"><img src="http://i.stack.imgur.com/rJvn9.png" alt="enter image description here"></a></p>

<p>You could probably build on something like this example. It doesn't display the information inside the figure (for now only using a <code>print()</code> statement), but it demonstrates a simple method of capturing clicks on <code>scatter</code> points and showing information for those points:</p>

<pre><code>import numpy as np
import matplotlib.pylab as pl

pl.close('all')

n = 10
lat = np.random.random(n)
lon = np.random.random(n)

speed = np.random.random(n)
rpm   = np.random.random(n)
temp  = np.random.random(n)

def on_click(event):
    i = event.ind[0]
    print('lon={0:.2f}, lat={1:.2f}: V={2:.2f}, RPM={3:.2f}, T={4:.2f}'\
        .format(lon[i], lat[i], speed[i], rpm[i], temp[i])) 

fig=pl.figure()
pl.plot(lon, lat, '-')
pl.scatter(lon, lat, picker=True)
fig.canvas.mpl_connect('pick_event', on_click)
</code></pre>

<p>Clicking around a bit gives me:</p>

<pre><code>lon=0.63, lat=0.58: V=0.51, RPM=0.00, T=0.43
lon=0.41, lat=0.07: V=0.95, RPM=0.59, T=0.98
lon=0.86, lat=0.13: V=0.33, RPM=0.27, T=0.85
</code></pre>

python matplotlib