1

Here is what I tried:

def onpick3(event):
        ind = event.ind
        print 'onpick3 scatter:'

fig.scatter(t, p, color='b', zorder=10, label='label', picker=True)
fig.legend(loc=fills_legend_pos[index])
fig.canvas.mpl_connect('pick_event', onpick3)

And the error

AttributeError: 'AxesSubplot' object has no attribute 'canvas'

Edit: fig is of type AxesSubplot, and is instantiated like this

fig = plt.subplot2grid((i, i), (j, 0), rowspan=1, colspan=i)

What is the easiest way to add tooltips on my scatterplot? Please note that I want to keep my current framework, with calling fig.scatter, as these scatters are overlaid on an existing figure.

1
  • how is fig defined? despite calling it fig it appears to be an object with no canvas attribute! Commented Jun 17, 2014 at 22:53

1 Answer 1

2

subplot2grid() returns an Axes object, use it's figure attribute to get the figure object:

import pylab as pl
axes = pl.subplot2grid((2, 2), (0, 0), rowspan=1, colspan=1)
axes.figure.canvas.mpl_connect('pick_event', onpick3)
Sign up to request clarification or add additional context in comments.

1 Comment

Now I'm getting /usr/lib64/python2.7/site-packages/numexpr/necompiler.py:746: DeprecationWarning: using oa_ndim == 0 when op_axes is NULL is deprecated. Use oa_ndim == -1 or the MultiNew iterator for NumPy <1.8 compatibility and the tooltips don't show.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.