@@ -539,9 +539,12 @@ def __str__(self):
539
539
+ "(%g,%g;%gx%g)" % (self ._x , self ._y , self ._width , self ._height )
540
540
541
541
@docstring .dedent_interpd
542
- def __init__ (self , xy , width , height , ** kwargs ):
542
+ def __init__ (self , xy , width , height , angle = 0.0 , ** kwargs ):
543
543
"""
544
544
545
+ *angle*
546
+ rotation in degrees (anti-clockwise)
547
+
545
548
*fill* is a boolean indicating whether to fill the rectangle
546
549
547
550
Valid kwargs are:
@@ -554,6 +557,7 @@ def __init__(self, xy, width, height, **kwargs):
554
557
self ._y = xy [1 ]
555
558
self ._width = width
556
559
self ._height = height
560
+ self ._angle = angle
557
561
# Note: This cannot be calculated until this is added to an Axes
558
562
self ._rect_transform = transforms .IdentityTransform ()
559
563
@@ -574,7 +578,10 @@ def _update_patch_transform(self):
574
578
width = self .convert_xunits (self ._width )
575
579
height = self .convert_yunits (self ._height )
576
580
bbox = transforms .Bbox .from_bounds (x , y , width , height )
581
+ rot_trans = transforms .Affine2D ()
582
+ rot_trans .translate (- x , - y ).rotate_deg (self ._angle ).translate (x , y )
577
583
self ._rect_transform = transforms .BboxTransformTo (bbox )
584
+ self ._rect_transform += rot_trans
578
585
579
586
def get_patch_transform (self ):
580
587
self ._update_patch_transform ()
0 commit comments