[Matplotlib-users] pick events don't work with twiny

Joe Kington joferkington at gmail.com
Wed Jan 31 08:43:29 EST 2018


If you know the artists you'd like to fire pick events for, you can work
around it in a few different ways.  One option is to bind to mouse events
and handle firing off pick events in that callback.

Here's how mpldatacursor gets around the twinx/twiny issue:
https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/datacursor.py#L658

Cheers,
-Joe

On Wed, Jan 31, 2018 at 1:31 AM, V. Armando Solé <sole at esrf.fr> wrote:

> On 30/01/2018 17:27, Benjamin Root wrote:
> > I seem to recall someone once messing around with the zorder of the
> > axes object, but I forget if that actually worked. Of course the other
> > workaround is to make the axes with the pickable objects be the twined
> > axes.
> >
>
> I'm using something on those lines since some time that works for me
> since quite some time. Here is a code fragment:
>
>             self.ax = self.fig.add_axes([.15, .15, .75, .75],
> label="left")
>             self.ax2 = self.ax.twinx()
>             self.ax2.set_label("right")
>             # critical for picking!!!!
>             self.ax2.set_zorder(0)
>             self.ax2.set_autoscaley_on(True)
>             self.ax.set_zorder(1)
>             self.fig.sca(self.ax)
>
> Best regards,
>
> Armando
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180131/3bcd5661/attachment.html>


More information about the Matplotlib-users mailing list