From 64f425d843b5281c26bee55e64c9a077cd0fe26e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 21 Jan 2023 04:50:06 -0500 Subject: [PATCH] Include child Axes inaxes calculation This makes InsetAxes count for this field, and allows widgets to work in them. Fixes #25030 --- lib/matplotlib/backend_bases.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 8c11c73afb8c..800ad1b98a18 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2007,6 +2007,12 @@ def inaxes(self, xy): if a.patch.contains_point(xy) and a.get_visible()] if axes_list: axes = cbook._topmost_artist(axes_list) + prev_axes = None + while prev_axes != axes: + prev_axes = axes + axes_list = [a for a in axes.child_axes + if a.patch.contains_point(xy) and a.get_visible()] + axes = cbook._topmost_artist([axes, *axes_list]) else: axes = None