@@ -688,10 +688,15 @@ def __init__(self, xy, width, height, angle=0.0, **kwargs):
688
688
689
689
Patch .__init__ (self , ** kwargs )
690
690
691
- self ._x = xy [0 ]
692
- self ._y = xy [1 ]
691
+ self ._x0 = xy [0 ]
692
+ self ._y0 = xy [1 ]
693
+
693
694
self ._width = width
694
695
self ._height = height
696
+
697
+ self ._x1 = self ._x0 + self ._width
698
+ self ._y1 = self ._y0 + self ._height
699
+
695
700
self .angle = float (angle )
696
701
# Note: This cannot be calculated until this is added to an Axes
697
702
self ._rect_transform = transforms .IdentityTransform ()
@@ -708,13 +713,13 @@ def _update_patch_transform(self):
708
713
maxes it very important to call the accessor method and
709
714
not directly access the transformation member variable.
710
715
"""
711
- x = self .convert_xunits (self ._x )
712
- y = self .convert_yunits (self ._y )
713
- width = self .convert_xunits (self ._width )
714
- height = self .convert_yunits (self ._height )
715
- bbox = transforms .Bbox .from_bounds ( x , y , width , height )
716
+ x0 = self .convert_xunits (self ._x0 )
717
+ y0 = self .convert_yunits (self ._y0 )
718
+ x1 = self .convert_xunits (self ._x1 )
719
+ y1 = self .convert_yunits (self ._y1 )
720
+ bbox = transforms .Bbox .from_extents ( x0 , y0 , x1 , y1 )
716
721
rot_trans = transforms .Affine2D ()
717
- rot_trans .rotate_deg_around (x , y , self .angle )
722
+ rot_trans .rotate_deg_around (x0 , y0 , self .angle )
718
723
self ._rect_transform = transforms .BboxTransformTo (bbox )
719
724
self ._rect_transform += rot_trans
720
725
@@ -724,15 +729,15 @@ def get_patch_transform(self):
724
729
725
730
def get_x (self ):
726
731
"Return the left coord of the rectangle"
727
- return self ._x
732
+ return self ._x0
728
733
729
734
def get_y (self ):
730
735
"Return the bottom coord of the rectangle"
731
- return self ._y
736
+ return self ._y0
732
737
733
738
def get_xy (self ):
734
739
"Return the left and bottom coords of the rectangle"
735
- return self ._x , self ._y
740
+ return self ._x0 , self ._y0
736
741
737
742
def get_width (self ):
738
743
"Return the width of the rectangle"
@@ -748,7 +753,7 @@ def set_x(self, x):
748
753
749
754
ACCEPTS: float
750
755
"""
751
- self ._x = x
756
+ self ._x0 = x0
752
757
self .stale = True
753
758
754
759
def set_y (self , y ):
@@ -757,7 +762,7 @@ def set_y(self, y):
757
762
758
763
ACCEPTS: float
759
764
"""
760
- self ._y = y
765
+ self ._y0 = y0
761
766
self .stale = True
762
767
763
768
def set_xy (self , xy ):
@@ -766,7 +771,7 @@ def set_xy(self, xy):
766
771
767
772
ACCEPTS: 2-item sequence
768
773
"""
769
- self ._x , self ._y = xy
774
+ self ._x0 , self ._y0 = xy
770
775
self .stale = True
771
776
772
777
def set_width (self , w ):
@@ -776,6 +781,7 @@ def set_width(self, w):
776
781
ACCEPTS: float
777
782
"""
778
783
self ._width = w
784
+ self ._x1 = self ._x0 + w
779
785
self .stale = True
780
786
781
787
def set_height (self , h ):
@@ -785,6 +791,7 @@ def set_height(self, h):
785
791
ACCEPTS: float
786
792
"""
787
793
self ._height = h
794
+ self ._y1 = self ._y0 + h
788
795
self .stale = True
789
796
790
797
def set_bounds (self , * args ):
@@ -797,15 +804,17 @@ def set_bounds(self, *args):
797
804
l , b , w , h = args [0 ]
798
805
else :
799
806
l , b , w , h = args
800
- self ._x = l
801
- self ._y = b
807
+ self ._x0 = l
808
+ self ._y0 = b
802
809
self ._width = w
803
810
self ._height = h
811
+ self ._x0 = l + w
812
+ self ._y0 = b + h
804
813
self .stale = True
805
814
806
815
def get_bbox (self ):
807
- return transforms .Bbox .from_bounds (self ._x , self ._y ,
808
- self ._width , self ._height )
816
+ return transforms .Bbox .from_extents (self ._x0 , self ._y0 ,
817
+ self ._x1 , self ._y1 )
809
818
810
819
xy = property (get_xy , set_xy )
811
820
0 commit comments