File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 9
9
import matplotlib .pyplot as plt
10
10
import matplotlib .patches as mpatches
11
11
import matplotlib .transforms as mtransforms
12
+ from matplotlib .transforms import Affine2D , Bbox , TransformedBbox
12
13
from matplotlib .path import Path
13
14
from matplotlib .testing .decorators import image_comparison , check_figures_equal
14
15
@@ -744,3 +745,14 @@ def test_scale_swapping(fig_test, fig_ref):
744
745
ax .plot (x , np .exp (- (x ** 2 ) / 2 ) / np .sqrt (2 * np .pi ))
745
746
fig .canvas .draw ()
746
747
ax .set_yscale ('linear' )
748
+
749
+
750
+ def test_transformedbbox_contains ():
751
+ bb = TransformedBbox (Bbox .unit (), Affine2D ().rotate_deg (30 ))
752
+ assert bb .contains (.8 , .5 )
753
+ assert bb .contains (- .4 , .85 )
754
+ assert not bb .contains (.9 , .5 )
755
+ bb = TransformedBbox (Bbox .unit (), Affine2D ().translate (.25 , .5 ))
756
+ assert bb .contains (1.25 , 1.5 )
757
+ assert not bb .fully_contains (1.25 , 1.5 )
758
+ assert not bb .fully_contains (.1 , .1 )
Original file line number Diff line number Diff line change @@ -1138,6 +1138,14 @@ def get_points(self):
1138
1138
self ._check (points )
1139
1139
return points
1140
1140
1141
+ def contains (self , x , y ):
1142
+ # Docstring inherited.
1143
+ return self ._bbox .contains (* self ._transform .inverted ().transform ((x , y )))
1144
+
1145
+ def fully_contains (self , x , y ):
1146
+ # Docstring inherited.
1147
+ return self ._bbox .fully_contains (* self ._transform .inverted ().transform ((x , y )))
1148
+
1141
1149
1142
1150
class LockableBbox (BboxBase ):
1143
1151
"""
You can’t perform that action at this time.
0 commit comments