@@ -706,8 +706,8 @@ def __str__(self):
706
706
return fmt % pars
707
707
708
708
@docstring .dedent_interpd
709
- def __init__ (self , xy , width , height , angle = 0.0 ,
710
- rotate_around_center = False , ** kwargs ):
709
+ def __init__ (self , xy , width , height , angle = 0.0 , * ,
710
+ rotation_point = 'xy' , ** kwargs ):
711
711
"""
712
712
Parameters
713
713
----------
@@ -718,12 +718,11 @@ def __init__(self, xy, width, height, angle=0.0,
718
718
height : float
719
719
Rectangle height.
720
720
angle : float, default: 0
721
- Rotation in degrees anti-clockwise about *xy* if
722
- *rotate_around_center* if False, otherwise rotate around the
723
- center of the rectangle
724
- rotate_around_center : bool, default: False
725
- If True, the rotation is performed around the center of the
726
- rectangle.
721
+ Rotation in degrees anti-clockwise about the rotation point.
722
+ rotation_point : {'xy', 'center', (number, number)}, default: 'xy'
723
+ If ``'xy'``, rotate around the anchor point. If ``'center'`` rotate
724
+ around the center. If 2-tuple of number, rotate around these
725
+ coordinate.
727
726
728
727
Other Parameters
729
728
----------------
@@ -736,7 +735,7 @@ def __init__(self, xy, width, height, angle=0.0,
736
735
self ._width = width
737
736
self ._height = height
738
737
self .angle = float (angle )
739
- self .rotate_around_center = rotate_around_center
738
+ self .rotation_point = rotation_point
740
739
# Required for RectangleSelector with axes aspect ratio != 1
741
740
# The patch is defined in data coordinates and when changing the
742
741
# selector with square modifier and not in data coordinates, we need
@@ -763,11 +762,14 @@ def get_patch_transform(self):
763
762
# important to call the accessor method and not directly access the
764
763
# transformation member variable.
765
764
bbox = self .get_bbox ()
766
- if self .rotate_around_center :
765
+ if self .rotation_point == 'center' :
767
766
width , height = bbox .x1 - bbox .x0 , bbox .y1 - bbox .y0
768
767
rotation_point = bbox .x0 + width / 2. , bbox .y0 + height / 2.
769
- else :
768
+ elif self . rotation_point == 'xy' :
770
769
rotation_point = bbox .x0 , bbox .y0
770
+ elif (isinstance (self .rotation_point [0 ], Number ) and
771
+ isinstance (self .rotation_point [1 ], Number )):
772
+ rotation_point = self .rotation_point
771
773
return transforms .BboxTransformTo (bbox ) \
772
774
+ transforms .Affine2D () \
773
775
.translate (- rotation_point [0 ], - rotation_point [1 ]) \
@@ -1534,6 +1536,10 @@ def __init__(self, xy, width, height, angle=0, **kwargs):
1534
1536
self ._angle = angle
1535
1537
self ._path = Path .unit_circle ()
1536
1538
# Required for EllipseSelector with axes aspect ratio != 1
1539
+ # The patch is defined in data coordinates and when changing the
1540
+ # selector with square modifier and not in data coordinates, we need
1541
+ # to correct for the aspect ratio difference between the data and
1542
+ # display coordinate systems.
1537
1543
self ._aspect_ratio_correction = 1.0
1538
1544
# Note: This cannot be calculated until this is added to an Axes
1539
1545
self ._patch_transform = transforms .IdentityTransform ()