Subplots, axes labels and mouse events.

Hi all,

I have a figure which consists of three subplots, which I have defined as follows:
gs = gridspec.GridSpec(2, 2)
self.ax1 = plt.subplot(gs[0:, 0])
self.ax2 = plt.subplot(gs[1])
self.ax3 = plt.subplot(gs[3])
self.ax1.imshow(self.data, vmin=self.dataminzs, vmax=self.datamaxzs)
self.ax1.figure.canvas.mpl_connect('motion_notify_event', self._on_move)

The _on_move() callback is (currently) defined as:
def _on_move(self, event):
    if event.inaxes:
    ax = event.inaxes # the axes instance
    print('data coords %s %f %f' % (ax, event.xdata, event.ydata))

I want that when I hover the mouse over ax1 then ax2 and ax3 show the part of ax1 which is under
the cursor, with 2 different levels of zooms.

I want to limit the region where the _on_move() is called to ax1 and I struggle to get what I want.

I thought that calling
self.ax1.figure.canvas.mpl_connect('motion_notify_event', self._on_move)
would limit the area of my figure where the mouse event are caught to ax1, but it's not the case. I
see that even.inaxes is
picking that I'm on different part of the figure, the

print('data coords %s %f %f' % (ax, event.xdata, event.ydata))

shows different values for ax depending on where the mouse is over the figure

So I thought that I might be checking the attributes of event.inaxes to make sure I do what I need
to do only when the mouse is over ax1, but it seems that all the attributes of the Axes are not
passed to the _on_move() callback.

self.ax1.set_label('AX1') sets the ax1 label as expected, but if I test the event.inaxes.properties() in
my _on_move(), then the label attribute is not set anymore.

Is there a way to make sure the _on_move() is fired only on a specific area of my figure?

Any help appreciated.

Thanks.

?ric.

···

--
Un clavier azerty en vaut deux
----------------------------------------------------------
?ric Depagne

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180121/36929e6e/attachment.html>

Le dimanche 21 janvier 2018, 04:00:47 SAST ?ric Depagne a ?crit :
Hi all,

Not sure what I did wrong yesterday, but it seems that
self.ax1.set_label('AX1')
Indeed sets the label properly, and I can test that in the _on_move()

Sorry for the noise.

?ric.

···

Hi all,

I have a figure which consists of three subplots, which I have defined as
follows: gs = gridspec.GridSpec(2, 2)
self.ax1 = plt.subplot(gs[0:, 0])
self.ax2 = plt.subplot(gs[1])
self.ax3 = plt.subplot(gs[3])
self.ax1.imshow(self.data, vmin=self.dataminzs, vmax=self.datamaxzs)
self.ax1.figure.canvas.mpl_connect('motion_notify_event', self._on_move)

The _on_move() callback is (currently) defined as:
def _on_move(self, event):
    if event.inaxes:
    ax = event.inaxes # the axes instance
    print('data coords %s %f %f' % (ax, event.xdata, event.ydata))

I want that when I hover the mouse over ax1 then ax2 and ax3 show the part
of ax1 which is under the cursor, with 2 different levels of zooms.

I want to limit the region where the _on_move() is called to ax1 and I
struggle to get what I want.

I thought that calling
self.ax1.figure.canvas.mpl_connect('motion_notify_event', self._on_move)
would limit the area of my figure where the mouse event are caught to ax1,
but it's not the case. I see that even.inaxes is
picking that I'm on different part of the figure, the

print('data coords %s %f %f' % (ax, event.xdata, event.ydata))

shows different values for ax depending on where the mouse is over the
figure

So I thought that I might be checking the attributes of event.inaxes to make
sure I do what I need to do only when the mouse is over ax1, but it seems
that all the attributes of the Axes are not passed to the _on_move()
callback.

self.ax1.set_label('AX1') sets the ax1 label as expected, but if I test the
event.inaxes.properties() in my _on_move(), then the label attribute is not
set anymore.

Is there a way to make sure the _on_move() is fired only on a specific area
of my figure?

Any help appreciated.

Thanks.

?ric.

--
Un clavier azerty en vaut deux
----------------------------------------------------------
?ric Depagne

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180121/77456fdc/attachment.html&gt;