confused with name of certain events

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

confused with name of certain events

Jose Borreguero
Dear Matplotlib gurus,

The following example prints the event.name 
for two events: ​
'figure_enter_event' and 'axes_enter_event':

from __future__ import print_function
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.canvas.mpl_connect('figure_enter_event',
                       lambda event: print(f'enter figure: {event.name}'))
fig.canvas.mpl_connect('axes_enter_event',
                       lambda event: print(f'enter axes: {event.name}'))
plt.show()


This is what I get
​when ​
hovering the mouse
​ over the canvas:​

enter figure: figure_enter_event
enter axes: motion_notify_event
enter figure: figure_enter_event
enter axes: motion_notify_event


What is the reason for 'motion_notify_event' being the assigned name to axes_enter_event but not figure_enter_event
​ ?

Best,
.Jose​


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: confused with name of certain events

Benjamin Root
Jose,

First, bonus points for your excellent use of f-strings!

You are right. It is an odd inconsistency that I sort of noticed when I wrote my book. The 'figure_enter_event' is of type "Event", so its name falls back to the default of itself. Meanwhile, all of the other enter/leave events are of type LocationEvent, which have different default names.

Not sure if this is something that warrants fixing or not. We don't have really good documentation for the event system anyway, but this has been this way for a very long time.

What do you think? How is it impacting your use-case?

Cheers!
Ben Root


On Tue, Nov 7, 2017 at 5:19 PM, Jose Borreguero <[hidden email]> wrote:
Dear Matplotlib gurus,

The following example prints the event.name 
for two events: ​
'figure_enter_event' and 'axes_enter_event':

from __future__ import print_function
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.canvas.mpl_connect('figure_enter_event',
                       lambda event: print(f'enter figure: {event.name}'))
fig.canvas.mpl_connect('axes_enter_event',
                       lambda event: print(f'enter axes: {event.name}'))
plt.show()


This is what I get
​when ​
hovering the mouse
​ over the canvas:​

enter figure: figure_enter_event
enter axes: motion_notify_event
enter figure: figure_enter_event
enter axes: motion_notify_event


What is the reason for 'motion_notify_event' being the assigned name to axes_enter_event but not figure_enter_event
​ ?

Best,
.Jose​


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users