[wxmpl] mouse location (other PointEvents?) fail when two axes share same area

This is relating wxmpl (wxPython+matplotlib). version 2.0dev of wxmpl,
matplotlib ver 1.1.0, and wx version is 2.8.12.1.

Since wxmpl is a very "thin" layer above mpl, I believe this is an issue
with mpl.

I'm using wxmpl and trying to get mouse points and selection. This
fails when there is more than one axes in the same place, which I do
since I'm using twinx() in my original code.

I believe the issue is the overlapping of both axes on the same area.
The following code shows that overlapping two axes makes
the mouse events in the overlapped area fail. For example, the cursor
doesn't change in them and the crosshairs disappear (if enabled).
Removing the ax2 code, or just ensuring ax1 and ax2 do not overlap
allows all the events to reach the handler.

Any idea on how to receive mouse events from the overlapped area?

Thanks,
Oren

···

----------------------------------------------------

import wxmpl

if __name__ == '__main__':
   class MainWindow(wx.Frame):
       def __init__(self):
           wx.Frame.__init__(self, parent=None, title='Graph Test',
size=(700,700))

           self.plot = wxmpl.PlotPanel(self, -1, dpi=70)

           fig = self.plot.get_figure()
           ax1 = fig.add_axes((0.1, 0.1, .6, .6))
           ax1.plot([0,3], [-1,1])
           ax2 = fig.add_axes( (0.3, 0.3, .6, .6) )
           ax2.plot([2,4], [-10,10])

           wxmpl.EVT_POINT(self.plot, -1, self.handle_event)

           self.Show()

       def handle_event(self, event):
           print event, event.GetId()

   app = wx.App()
   mw = MainWindow()
   app.MainLoop()

Oren,

You identified the source of the problem correctly and this is a known issue. It used to be possible to do this, but due to changes needed to fix other bugs, thiis “feature” went away (I think at v1.0.0).

We agree that this isn’t desirable, but we have not found a suitable solution. There have been some discussion about this and proposed solutions. Here is one with possible hacks that might be useful.

http://old.nabble.com/onpick-on-a-2-y-plot-%28-via-twinx%28%29-%29-seems-to-only-allow-picking-of-second-axes%27s-artists-td25049128.html

I hope this helps!
Ben Root

···

On Tue, Feb 14, 2012 at 4:54 AM, Oren Gampel <oren@…3967…> wrote:

This is relating wxmpl (wxPython+matplotlib). version 2.0dev of wxmpl,

matplotlib ver 1.1.0, and wx version is 2.8.12.1.

Since wxmpl is a very “thin” layer above mpl, I believe this is an issue

with mpl.

I’m using wxmpl and trying to get mouse points and selection. This

fails when there is more than one axes in the same place, which I do

since I’m using twinx() in my original code.

I believe the issue is the overlapping of both axes on the same area.

The following code shows that overlapping two axes makes

the mouse events in the overlapped area fail. For example, the cursor

doesn’t change in them and the crosshairs disappear (if enabled).

Removing the ax2 code, or just ensuring ax1 and ax2 do not overlap

allows all the events to reach the handler.

Any idea on how to receive mouse events from the overlapped area?

Thanks,

Oren