Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## matplotlib-users

 [Matplotlib-users] Pick event and annotate From: Nils Wagner - 2010-02-10 11:21:21 ```Hi all, How can I combine onpick events with annotate ? Any pointer would be appreciated. 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(100), 'o', picker=5) # 5 points tolerance def onpick(event): thisline = event.artist xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind print 'onpick points:', zip(xdata[ind], ydata[ind]), ind ax.annotate('Test',xy=(ind, ydata[ind]),horizontalalignment='left',verticalalignment='top') # ax.redraw_in_frame() fig.canvas.mpl_connect('pick_event', onpick) plt.show() Thanks in advance. Nils ```
 Re: [Matplotlib-users] Pick event and annotate From: John Hunter - 2010-02-10 15:42:43 ```On Wed, Feb 10, 2010 at 4:43 AM, Nils Wagner wrote: > Hi all, > > How can I combine onpick events with annotate ? > Any pointer would be appreciated. > > 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(100), 'o', picker=5)  # 5 > points tolerance > > def onpick(event): >     thisline = event.artist >     xdata = thisline.get_xdata() >     ydata = thisline.get_ydata() >     ind = event.ind >     print 'onpick points:', zip(xdata[ind], ydata[ind]), > ind >     ax.annotate('Test',xy=(ind, > ydata[ind]),horizontalalignment='left',verticalalignment='top') > #   ax.redraw_in_frame() You need to call fig.canvas.draw() at the end of onpick. JDH > > fig.canvas.mpl_connect('pick_event', onpick) > > plt.show() > > > > Thanks in advance. > >                          Nils > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```