@@ -39,6 +39,36 @@ def cla(self):
39
39
self .xaxis .set_zorder (2.5 )
40
40
self .yaxis .set_zorder (2.5 )
41
41
42
+ # Overwritten so events that actually happened in the host axes still count
43
+ def pick (self , mouseevent ):
44
+ """
45
+ call signature::
46
+
47
+ pick(mouseevent)
48
+
49
+ each child artist will fire a pick event if *mouseevent* is over
50
+ the artist and the artist has picker set
51
+ """
52
+ # Pick self
53
+ if self .pickable ():
54
+ picker = self .get_picker ()
55
+ if six .callable (picker ):
56
+ inside , prop = picker (self , mouseevent )
57
+ else :
58
+ inside , prop = self .contains (mouseevent )
59
+ if inside :
60
+ self .figure .canvas .pick_event (mouseevent , self , ** prop )
61
+
62
+ # Pick children
63
+ for a in self .get_children ():
64
+ # make sure the event happened in the same axes (never happens but
65
+ # whatever) or in host axes
66
+ ax = getattr (a , 'axes' , None )
67
+ if mouseevent .inaxes is None or ax is None or \
68
+ mouseevent .inaxes == ax or \
69
+ (hasattr (mouseevent .inaxes , "parasites" ) and \
70
+ self in mouseevent .inaxes .parasites ):
71
+ a .pick (mouseevent )
42
72
43
73
@functools .lru_cache (None )
44
74
def parasite_axes_class_factory (axes_class = None ):
@@ -266,6 +296,45 @@ def cla(self):
266
296
ax .cla ()
267
297
self ._get_base_axes_attr ("cla" )(self )
268
298
299
+ # Need to overwrite this so children of parasite axes get picked as well
300
+ def pick (self , mouseevent ):
301
+ """
302
+ call signature::
303
+
304
+ pick(mouseevent)
305
+
306
+ each child artist will fire a pick event if *mouseevent* is over
307
+ the artist and the artist has picker set
308
+ """
309
+ # Pick self
310
+ if self .pickable ():
311
+ picker = self .get_picker ()
312
+ if six .callable (picker ):
313
+ inside , prop = picker (self , mouseevent )
314
+ else :
315
+ inside , prop = self .contains (mouseevent )
316
+ if inside :
317
+ self .figure .canvas .pick_event (mouseevent , self , ** prop )
318
+
319
+ # Pick children
320
+ for a in self .get_children ():
321
+ # make sure the event happened in the same axes
322
+ ax = getattr (a , 'axes' , None )
323
+ if mouseevent .inaxes is None or ax is None or \
324
+ mouseevent .inaxes == ax :
325
+ # we need to check if mouseevent.inaxes is None
326
+ # because some objects associated with an axes (e.g., a
327
+ # tick label) can be outside the bounding box of the
328
+ # axes and inaxes will be None
329
+ # also check that ax is None so that it traverse objects
330
+ # which do no have an axes property but children might
331
+ a .pick (mouseevent )
332
+
333
+ # Pick parasite axes
334
+ for a in self .parasites :
335
+ a .pick (mouseevent )
336
+
337
+
269
338
def twinx (self , axes_class = None ):
270
339
"""
271
340
create a twin of Axes for generating a plot with a sharex
0 commit comments