Skip to content

Commit 0882ed8

Browse files
author
astromancer
committed
update setters
1 parent f0392f6 commit 0882ed8

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

lib/matplotlib/patches.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,19 +1579,9 @@ def __init__(self, xy, r, width, angle=0.0, **kwargs):
15791579
"""
15801580
super().__init__(**kwargs)
15811581

1582-
if np.shape(r) == (2,):
1583-
self.a, self.b = r
1584-
elif np.shape(r) == ():
1585-
self.a = self.b = float(r)
1586-
else:
1587-
raise ValueError("Parameter 'r' must be one or two floats")
1588-
1589-
if min(self.a, self.b) <= width:
1590-
raise ValueError(
1591-
'Width of annulus must be smaller than semi-minor axis')
1592-
1593-
self._center = xy
1594-
self._width = width
1582+
self.set_radii(r)
1583+
self.center = xy
1584+
self.width = width
15951585
self.angle = angle
15961586
self._path = None
15971587

@@ -1613,6 +1603,7 @@ def set_center(self, xy):
16131603
xy : (float, float)
16141604
"""
16151605
self._center = xy
1606+
self._path = None
16161607
self.stale = True
16171608

16181609
def get_center(self):
@@ -1629,7 +1620,12 @@ def set_width(self, width):
16291620
----------
16301621
width : float
16311622
"""
1623+
if min(self.a, self.b) <= width:
1624+
raise ValueError(
1625+
'Width of annulus must be smaller than semi-minor axis')
1626+
16321627
self._width = width
1628+
self._path = None
16331629
self.stale = True
16341630

16351631
def get_width(self):
@@ -1649,6 +1645,7 @@ def set_angle(self, angle):
16491645
angle : float
16501646
"""
16511647
self._angle = angle
1648+
self._path = None
16521649
self.stale = True
16531650

16541651
def get_angle(self):
@@ -1666,6 +1663,7 @@ def set_semimajor(self, a):
16661663
a : float
16671664
"""
16681665
self.a = float(a)
1666+
self._path = None
16691667
self.stale = True
16701668

16711669
def set_semiminor(self, b):
@@ -1677,20 +1675,34 @@ def set_semiminor(self, b):
16771675
b : float
16781676
"""
16791677
self.b = float(b)
1678+
self._path = None
16801679
self.stale = True
16811680

1682-
def set_radii(self, radii):
1681+
def set_radii(self, r):
16831682
"""
16841683
Set the both the semi-major (*a*) and -minor radii (*b*) of the
16851684
annulus.
16861685
16871686
Parameters
16881687
----------
1689-
radii : (float, float)
1688+
r : (float, float)
16901689
"""
1691-
self.a, self.b = radii
1690+
if np.shape(r) == (2,):
1691+
self.a, self.b = r
1692+
elif np.shape(r) == ():
1693+
self.a = self.b = float(r)
1694+
else:
1695+
raise ValueError("Parameter 'r' must be one or two floats.")
1696+
1697+
self._path = None
16921698
self.stale = True
16931699

1700+
def get_radii(self):
1701+
return self.a, self.b
1702+
1703+
# alias
1704+
radii = property(get_radii, set_radii)
1705+
16941706
def _transform_verts(self, verts, a, b):
16951707
return transforms.Affine2D() \
16961708
.scale(*self._convert_xy_units((a, b))) \

0 commit comments

Comments
 (0)