File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ Add ``inaxes `` method to Figure
3
+ -------------------------------------------------------------
4
+
5
+ The `Figure ` class has now an ``inaxes `` method to check whether a point is in an axes
6
+ and returns the topmost axes, else None.
Original file line number Diff line number Diff line change @@ -1532,6 +1532,31 @@ def get_axes(self):
1532
1532
"""
1533
1533
return self .axes
1534
1534
1535
+ def inaxes (self , xy ):
1536
+ """
1537
+ Check if a point is in an axes.
1538
+
1539
+ Parameters
1540
+ ----------
1541
+ xy : tuple or list
1542
+ (x,y) coordinates.
1543
+ x position - pixels from left of canvas.
1544
+ y position - pixels from bottom of canvas.
1545
+
1546
+ Returns
1547
+ -------
1548
+ axes: topmost axes containing the point, or None if no axes.
1549
+
1550
+ """
1551
+ axes_list = [a for a in self .get_axes () if a .patch .contains_point (xy )]
1552
+
1553
+ if axes_list :
1554
+ axes = max (reversed (axes_list ), key = lambda x : x .zorder )
1555
+ else :
1556
+ axes = None
1557
+
1558
+ return axes
1559
+
1535
1560
@docstring .dedent_interpd
1536
1561
def legend (self , * args , ** kwargs ):
1537
1562
"""
You can’t perform that action at this time.
0 commit comments