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

Benjamin Root ben.v.root at gmail.com
Tue Jan 30 11:27:35 EST 2018


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.

Ben Root


On Tue, Jan 30, 2018 at 11:15 AM, Neal Becker <ndbecker2 at gmail.com> wrote:

> Benjamin Root wrote:
>
> > The problem is that the second axes is getting the pick events, because
> it
> > is on top of the first axes. This has been a problem for a long time, and
> > we haven't found a good solution for it.
> >
> > Ben Root
> >
>
> That was my guess.  Is there any workaround?
>
> > On Tue, Jan 30, 2018 at 10:10 AM, Neal Becker
> > <ndbecker2 at gmail.com> wrote:
> >
> >> I find that pick events are fine until I add twiny.  In that case,
> >> nothing happens when clicking.
> >>
> >> THe code outline is like:
> >>
> >> fig, ax = plt.subplots()
> >> ax2 = ax.twiny()
> >> ax.semilogy(...)
> >> fig.canvas.mpl_connect('pick_event', onpick)
> >> ax2_xaxis = np.linspace (*ax.get_xlim(), endpoint=True,)/conversion
> >> ax2.semilogy (ax2_xaxis, np.ones (len(ax2_xaxis)) * 1e-3, alpha=0)
> >> ax2.set_xlabel(...)
> >> ...
> >>
> >> removing all the lines about ax2 will restore pick function.
> >>
>
>
> _______________________________________________
> 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/20180130/0b6c78b8/attachment.html>


More information about the Matplotlib-users mailing list