File tree 2 files changed +34
-0
lines changed 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -799,6 +799,10 @@ def get_height(self):
799
799
"""Return the height of the rectangle."""
800
800
return self ._height
801
801
802
+ def get_angle (self ):
803
+ """Get the rotation angle in degrees."""
804
+ return self .angle
805
+
802
806
def set_x (self , x ):
803
807
"""Set the left coordinate of the rectangle."""
804
808
self ._x0 = x
@@ -809,6 +813,15 @@ def set_y(self, y):
809
813
self ._y0 = y
810
814
self .stale = True
811
815
816
+ def set_angle (self , angle ):
817
+ """
818
+ Set the rotation angle in degrees.
819
+
820
+ The rotation is performed anti-clockwise around *xy*.
821
+ """
822
+ self .angle = angle
823
+ self .stale = True
824
+
812
825
def set_xy (self , xy ):
813
826
"""
814
827
Set the left and bottom coordinates of the rectangle.
Original file line number Diff line number Diff line change @@ -76,6 +76,27 @@ def test_rotate_rect():
76
76
assert_almost_equal (rect1 .get_verts (), new_verts )
77
77
78
78
79
+ @check_figures_equal (extensions = ['png' ])
80
+ def test_rotate_rect_draw (fig_test , fig_ref ):
81
+ ax_test = fig_test .add_subplot ()
82
+ ax_ref = fig_ref .add_subplot ()
83
+
84
+ loc = (0 , 0 )
85
+ width , height = (1 , 1 )
86
+ angle = 30
87
+ rect_ref = Rectangle (loc , width , height , angle = angle )
88
+ ax_ref .add_patch (rect_ref )
89
+ assert rect_ref .get_angle () == angle
90
+
91
+ # Check that when the angle is updated after adding to an axes, that the
92
+ # patch is marked stale and redrawn in the correct location
93
+ rect_test = Rectangle (loc , width , height )
94
+ assert rect_test .get_angle () == 0
95
+ ax_test .add_patch (rect_test )
96
+ rect_test .set_angle (angle )
97
+ assert rect_test .get_angle () == angle
98
+
99
+
79
100
def test_negative_rect ():
80
101
# These two rectangles have the same vertices, but starting from a
81
102
# different point. (We also drop the last vertex, which is a duplicate.)
You can’t perform that action at this time.
0 commit comments