@@ -1557,15 +1557,6 @@ class Annulus(Patch):
15571557 An elliptical annulus.
15581558 """
15591559
1560- def __str__ (self ):
1561- if self .a == self .b :
1562- r = self .a
1563- else :
1564- r = (self .a , self .b )
1565-
1566- return "Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s)" % \
1567- (self .center [0 ], self .center [1 ], r , self .width , self .angle )
1568-
15691560 @docstring .dedent_interpd
15701561 def __init__ (self , xy , r , width , angle = 0.0 , ** kwargs ):
15711562 """
@@ -1577,7 +1568,7 @@ def __init__(self, xy, r, width, angle=0.0, **kwargs):
15771568 - If two floats: semi-major and -minor axes of outer
15781569 ellipse
15791570 width : float
1580- Width of the annulus.
1571+ Width (thickness) of the annulus ring .
15811572 angle: float, default=0
15821573 Rotation angle in degrees (anti-clockwise). Ignored for circular
15831574 annuli (ie. if *r* is a scalar).
@@ -1593,29 +1584,118 @@ def __init__(self, xy, r, width, angle=0.0, **kwargs):
15931584 elif np .shape (r ) == ():
15941585 self .a = self .b = float (r )
15951586 else :
1596- raise ValueError (
1597- "Parameter 'r' must be one or two floats" )
1587+ raise ValueError ("Parameter 'r' must be one or two floats" )
15981588
15991589 if min (self .a , self .b ) <= width :
16001590 raise ValueError (
16011591 'Width of annulus must be smaller than semi-minor axis' )
16021592
1603- self .center = xy
1604- self .width = width
1593+ self ._center = xy
1594+ self ._width = width
16051595 self .angle = angle
16061596 self ._path = None
1597+
1598+ def __str__ (self ):
1599+ if self .a == self .b :
1600+ r = self .a
1601+ else :
1602+ r = (self .a , self .b )
1603+
1604+ return "Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s)" % \
1605+ (* self .center , r , self .width , self .angle )
1606+
1607+ def set_center (self , xy ):
1608+ """
1609+ Set the center of the annulus.
1610+
1611+ Parameters
1612+ ----------
1613+ xy : (float, float)
1614+ """
1615+ self ._center = xy
1616+ self .stale = True
1617+
1618+ def get_center (self ):
1619+ """Return the center of the annulus."""
1620+ return self ._center
1621+
1622+ center = property (get_center , set_center )
1623+
1624+ def set_width (self , width ):
1625+ """
1626+ Set the width (thickness) of the annulus ring.
16071627
1628+ Parameters
1629+ ----------
1630+ width : float
1631+ """
1632+ self ._width = width
1633+ self .stale = True
1634+
1635+ def get_width (self ):
1636+ """
1637+ Return the width (thickness) of the annulus ring.
1638+ """
1639+ return self ._width
1640+
1641+ width = property (get_width , set_width )
1642+
1643+ def set_angle (self , angle ):
1644+ """
1645+ Set the tilt angle of the annulus.
1646+
1647+ Parameters
1648+ ----------
1649+ angle : float
1650+ """
1651+ self ._angle = angle
1652+ self .stale = True
1653+
1654+ def get_angle (self ):
1655+ """Return the angle of the annulus."""
1656+ return self ._angle
1657+
1658+ angle = property (get_angle , set_angle )
1659+
1660+ def set_semimajor (self , a ):
1661+ """
1662+ Set the semi-major axis *a* of the annulus.
1663+
1664+ Parameters
1665+ ----------
1666+ a : float
1667+ """
1668+ self .a = float (a )
1669+ self .stale = True
1670+
1671+ def set_semiminor (self , b ):
1672+ """
1673+ Set the semi-minor axis *b* of the annulus.
1674+
1675+ Parameters
1676+ ----------
1677+ b : float
1678+ """
1679+ self .b = float (b )
1680+ self .stale = True
1681+
1682+ def set_radii (self , radii ):
1683+ """
1684+ Set the both the semi-major (*a*) and -minor radii (*b*) of the annulus.
1685+
1686+ Parameters
1687+ ----------
1688+ radii : (float, float)
1689+ """
1690+ self .a , self .b = radii
1691+ self .stale = True
1692+
16081693 def _transform_verts (self , verts , a , b ):
1609- center = (self .convert_xunits (self .center [0 ]),
1610- self .convert_yunits (self .center [1 ]))
1611- a = self .convert_xunits (a )
1612- b = self .convert_yunits (b )
1613- tr = transforms .Affine2D () \
1614- .scale (a , b ) \
1694+ return transforms .Affine2D () \
1695+ .scale (* self ._convert_xy_units ((a , b ))) \
16151696 .rotate_deg (self .angle ) \
1616- .translate (* center )
1617-
1618- return tr .transform (verts )
1697+ .translate (* self ._convert_xy_units (self .center )) \
1698+ .transform (verts )
16191699
16201700 def _recompute_path (self ):
16211701 # circular arc
0 commit comments