Skip to content

Commit f40607e

Browse files
committed
Convert units when returning Rect bbox
1 parent 03fba6b commit f40607e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/matplotlib/patches.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,7 @@ def _update_patch_transform(self):
687687
makes it very important to call the accessor method and
688688
not directly access the transformation member variable.
689689
"""
690-
x0 = self.convert_xunits(self._x0)
691-
y0 = self.convert_yunits(self._y0)
692-
x1 = self.convert_xunits(self._x1)
693-
y1 = self.convert_yunits(self._y1)
690+
x0, y0, x1, y1 = self._convert_units()
694691
bbox = transforms.Bbox.from_extents(x0, y0, x1, y1)
695692
rot_trans = transforms.Affine2D()
696693
rot_trans.rotate_deg_around(x0, y0, self.angle)
@@ -703,6 +700,16 @@ def _update_x1(self):
703700
def _update_y1(self):
704701
self._y1 = self._y0 + self._height
705702

703+
def _convert_units(self):
704+
'''
705+
Convert bounds of the rectangle
706+
'''
707+
x0 = self.convert_xunits(self._x0)
708+
y0 = self.convert_yunits(self._y0)
709+
x1 = self.convert_xunits(self._x1)
710+
y1 = self.convert_yunits(self._y1)
711+
return x0, y0, x1, y1
712+
706713
def get_patch_transform(self):
707714
self._update_patch_transform()
708715
return self._rect_transform
@@ -720,7 +727,7 @@ def get_xy(self):
720727
return self._x0, self._y0
721728

722729
def get_width(self):
723-
"Return the width of the rectangle"
730+
"Return the width of the rectangle"
724731
return self._width
725732

726733
def get_height(self):
@@ -797,6 +804,7 @@ def set_bounds(self, *args):
797804
self.stale = True
798805

799806
def get_bbox(self):
807+
x0, y0, x1, y1 = self._convert_units()
800808
return transforms.Bbox.from_extents(self._x0, self._y0,
801809
self._x1, self._y1)
802810

0 commit comments

Comments
 (0)