Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e1e701

Browse files
authored
Merge pull request #12754 from meeseeksmachine/auto-backport-of-pr-12737-on-v3.0.x
Backport PR #12737 on branch v3.0.x (Improve docstring of Arc)
2 parents 64d0564 + 37c3867 commit 7e1e701

File tree

1 file changed

+54
-46
lines changed

1 file changed

+54
-46
lines changed

lib/matplotlib/patches.py

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,14 +1533,15 @@ def get_radius(self):
15331533

15341534
class Arc(Ellipse):
15351535
"""
1536-
An elliptical arc. Because it performs various optimizations, it
1537-
can not be filled.
1538-
1539-
The arc must be used in an :class:`~matplotlib.axes.Axes`
1540-
instance---it can not be added directly to a
1541-
:class:`~matplotlib.figure.Figure`---because it is optimized to
1542-
only render the segments that are inside the axes bounding box
1543-
with high resolution.
1536+
An elliptical arc, i.e. a segment of an ellipse.
1537+
1538+
Due to internal optimizations, there are certain restrictions on using Arc:
1539+
1540+
- The arc cannot be filled.
1541+
1542+
- The arc must be used in an :class:`~.axes.Axes` instance---it can not be
1543+
added directly to a `.Figure`---because it is optimized to only render
1544+
the segments that are inside the axes bounding box with high resolution.
15441545
"""
15451546
def __str__(self):
15461547
pars = (self.center[0], self.center[1], self.width,
@@ -1553,32 +1554,35 @@ def __str__(self):
15531554
def __init__(self, xy, width, height, angle=0.0,
15541555
theta1=0.0, theta2=360.0, **kwargs):
15551556
"""
1556-
The following args are supported:
1557-
1558-
*xy*
1559-
center of ellipse
1560-
1561-
*width*
1562-
length of horizontal axis
1563-
1564-
*height*
1565-
length of vertical axis
1557+
Parameters
1558+
----------
1559+
xy : (float, float)
1560+
The center of the ellipse.
15661561
1567-
*angle*
1568-
rotation in degrees (anti-clockwise)
1562+
width : float
1563+
The length of the horizontal axis.
15691564
1570-
*theta1*
1571-
starting angle of the arc in degrees
1565+
height : float
1566+
The length of the vertical axis.
15721567
1573-
*theta2*
1574-
ending angle of the arc in degrees
1568+
angle : float
1569+
Rotation of the ellipse in degrees (anti-clockwise).
15751570
1576-
If *theta1* and *theta2* are not provided, the arc will form a
1577-
complete ellipse.
1571+
theta1, theta2 : float, optional
1572+
Starting and ending angles of the arc in degrees. These values
1573+
are relative to *angle*, .e.g. if *angle* = 45 and *theta1* = 90
1574+
the absolute starting angle is 135.
1575+
Default *theta1* = 0, *theta2* = 360, i.e. a complete ellipse.
15781576
1579-
Valid kwargs are:
1577+
Other Parameters
1578+
----------------
1579+
**kwargs : `.Patch` properties
1580+
Most `.Patch` properties are supported as keyword arguments,
1581+
with the exception of *fill* and *facecolor* because filling is
1582+
not supported.
15801583
15811584
%(Patch)s
1585+
15821586
"""
15831587
fill = kwargs.setdefault('fill', False)
15841588
if fill:
@@ -1592,12 +1596,16 @@ def __init__(self, xy, width, height, angle=0.0,
15921596
@artist.allow_rasterization
15931597
def draw(self, renderer):
15941598
"""
1599+
Draw the arc to the given *renderer*.
1600+
1601+
Notes
1602+
-----
15951603
Ellipses are normally drawn using an approximation that uses
15961604
eight cubic Bezier splines. The error of this approximation
15971605
is 1.89818e-6, according to this unverified source:
15981606
1599-
Lancaster, Don. Approximating a Circle or an Ellipse Using
1600-
Four Bezier Cubic Splines.
1607+
Lancaster, Don. *Approximating a Circle or an Ellipse Using
1608+
Four Bezier Cubic Splines.*
16011609
16021610
http://www.tinaja.com/glib/ellipse4.pdf
16031611
@@ -1613,27 +1621,27 @@ def draw(self, renderer):
16131621
with each visible arc using a fixed number of spline segments
16141622
(8). The algorithm proceeds as follows:
16151623
1616-
1. The points where the ellipse intersects the axes bounding
1617-
box are located. (This is done be performing an inverse
1618-
transformation on the axes bbox such that it is relative
1619-
to the unit circle -- this makes the intersection
1620-
calculation much easier than doing rotated ellipse
1621-
intersection directly).
1624+
1. The points where the ellipse intersects the axes bounding
1625+
box are located. (This is done be performing an inverse
1626+
transformation on the axes bbox such that it is relative
1627+
to the unit circle -- this makes the intersection
1628+
calculation much easier than doing rotated ellipse
1629+
intersection directly).
16221630
1623-
This uses the "line intersecting a circle" algorithm
1624-
from:
1631+
This uses the "line intersecting a circle" algorithm
1632+
from:
16251633
1626-
Vince, John. Geometry for Computer Graphics: Formulae,
1627-
Examples & Proofs. London: Springer-Verlag, 2005.
1634+
Vince, John. *Geometry for Computer Graphics: Formulae,
1635+
Examples & Proofs.* London: Springer-Verlag, 2005.
16281636
1629-
2. The angles of each of the intersection points are
1630-
calculated.
1637+
2. The angles of each of the intersection points are
1638+
calculated.
16311639
1632-
3. Proceeding counterclockwise starting in the positive
1633-
x-direction, each of the visible arc-segments between the
1634-
pairs of vertices are drawn using the Bezier arc
1635-
approximation technique implemented in
1636-
:meth:`matplotlib.path.Path.arc`.
1640+
3. Proceeding counterclockwise starting in the positive
1641+
x-direction, each of the visible arc-segments between the
1642+
pairs of vertices are drawn using the Bezier arc
1643+
approximation technique implemented in
1644+
:meth:`matplotlib.path.Path.arc`.
16371645
"""
16381646
if not hasattr(self, 'axes'):
16391647
raise RuntimeError('Arcs can only be used in Axes instances')

0 commit comments

Comments
 (0)