Skip to content

Commit 78b76b0

Browse files
committed
Cleanup patches docstrings.
1 parent 154a936 commit 78b76b0

File tree

1 file changed

+46
-59
lines changed

1 file changed

+46
-59
lines changed

lib/matplotlib/patches.py

+46-59
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ def get_verts(self):
9999
"""
100100
Return a copy of the vertices used in this patch.
101101
102-
If the patch contains Bezier curves, the curves will be
103-
interpolated by line segments. To access the curves as
104-
curves, use :meth:`get_path`.
102+
If the patch contains Bezier curves, the curves will be interpolated by
103+
line segments. To access the curves as curves, use `get_path`.
105104
"""
106105
trans = self.get_transform()
107106
path = self.get_path()
@@ -263,15 +262,15 @@ def get_transform(self):
263262

264263
def get_data_transform(self):
265264
"""
266-
Return the :class:`~matplotlib.transforms.Transform` instance which
267-
maps data coordinates to physical coordinates.
265+
Return the `~.transforms.Transform` mapping data coordinates to
266+
physical coordinates.
268267
"""
269268
return artist.Artist.get_transform(self)
270269

271270
def get_patch_transform(self):
272271
"""
273-
Return the :class:`~matplotlib.transforms.Transform` instance which
274-
takes patch coordinates to data coordinates.
272+
Return the `~.transforms.Transform` instance mapping patch coordinates
273+
to data coordinates.
275274
276275
For example, one may define a patch of a circle which represents a
277276
radius of 5 by providing coordinates for a unit circle, and a
@@ -968,7 +967,7 @@ def __str__(self):
968967
@docstring.dedent_interpd
969968
def __init__(self, path, **kwargs):
970969
"""
971-
*path* is a :class:`matplotlib.path.Path` object.
970+
*path* is a `~.path.Path` object.
972971
973972
Valid keyword arguments are:
974973
@@ -1211,9 +1210,9 @@ def __init__(self, x, y, dx, dy, width=1.0, **kwargs):
12111210
12121211
See Also
12131212
--------
1214-
:class:`FancyArrow` :
1213+
FancyArrow
12151214
Patch that allows independent control of the head and tail
1216-
properties
1215+
properties.
12171216
"""
12181217
super().__init__(**kwargs)
12191218
self._patch_transform = (
@@ -1349,9 +1348,9 @@ def __init__(self, xy, radius=5,
13491348
** kwargs):
13501349
"""
13511350
Create a circle at *xy* = (*x*, *y*) with given *radius*.
1352-
This circle is approximated by a regular polygon with
1353-
*resolution* sides. For a smoother circle drawn with splines,
1354-
see :class:`~matplotlib.patches.Circle`.
1351+
1352+
This circle is approximated by a regular polygon with *resolution*
1353+
sides. For a smoother circle drawn with splines, see `Circle`.
13551354
13561355
Valid keyword arguments are:
13571356
@@ -1463,10 +1462,10 @@ def __str__(self):
14631462
@docstring.dedent_interpd
14641463
def __init__(self, xy, radius=5, **kwargs):
14651464
"""
1466-
Create true circle at center *xy* = (*x*, *y*) with given
1467-
*radius*. Unlike :class:`~matplotlib.patches.CirclePolygon`
1468-
which is a polygonal approximation, this uses Bezier splines
1469-
and is much closer to a scale-free circle.
1465+
Create a true circle at center *xy* = (*x*, *y*) with given *radius*.
1466+
1467+
Unlike `CirclePolygon` which is a polygonal approximation, this uses
1468+
Bezier splines and is much closer to a scale-free circle.
14701469
14711470
Valid keyword arguments are:
14721471
@@ -1503,7 +1502,7 @@ class Arc(Ellipse):
15031502
15041503
- The arc cannot be filled.
15051504
1506-
- The arc must be used in an :class:`~.axes.Axes` instance---it can not be
1505+
- The arc must be used in an `~.axes.Axes` instance---it can not be
15071506
added directly to a `.Figure`---because it is optimized to only render
15081507
the segments that are inside the axes bounding box with high resolution.
15091508
"""
@@ -1605,8 +1604,7 @@ def draw(self, renderer):
16051604
3. Proceeding counterclockwise starting in the positive
16061605
x-direction, each of the visible arc-segments between the
16071606
pairs of vertices are drawn using the Bezier arc
1608-
approximation technique implemented in
1609-
:meth:`matplotlib.path.Path.arc`.
1607+
approximation technique implemented in `.Path.arc`.
16101608
"""
16111609
if not hasattr(self, 'axes'):
16121610
raise RuntimeError('Arcs can only be used in Axes instances')
@@ -1705,8 +1703,7 @@ def segment_circle_intersect(x0, y0, x1, y1):
17051703
def bbox_artist(artist, renderer, props=None, fill=True):
17061704
"""
17071705
This is a debug function to draw a rectangle around the bounding
1708-
box returned by
1709-
:meth:`~matplotlib.artist.Artist.get_window_extent` of an artist,
1706+
box returned by an artist's `.Artist.get_window_extent`
17101707
to test whether the artist is returning the correct bbox.
17111708
17121709
*props* is a dict of rectangle props with the additional property
@@ -1737,8 +1734,7 @@ def bbox_artist(artist, renderer, props=None, fill=True):
17371734
def draw_bbox(bbox, renderer, color='k', trans=None):
17381735
"""
17391736
This is a debug function to draw a rectangle around the bounding
1740-
box returned by
1741-
:meth:`~matplotlib.artist.Artist.get_window_extent` of an artist,
1737+
box returned by an artist's `.Artist.get_window_extent`
17421738
to test whether the artist is returning the correct bbox.
17431739
"""
17441740

@@ -1857,8 +1853,8 @@ def _register_style(style_list, cls=None, *, name=None):
18571853

18581854
class BoxStyle(_Style):
18591855
"""
1860-
:class:`BoxStyle` is a container class which defines several
1861-
boxstyle classes, which are used for :class:`FancyBboxPatch`.
1856+
`BoxStyle` is a container class which defines several
1857+
boxstyle classes, which are used for `FancyBboxPatch`.
18621858
18631859
A style object can be created as::
18641860
@@ -2627,10 +2623,9 @@ def get_bbox(self):
26272623

26282624
class ConnectionStyle(_Style):
26292625
"""
2630-
:class:`ConnectionStyle` is a container class which defines
2626+
`ConnectionStyle` is a container class which defines
26312627
several connectionstyle classes, which is used to create a path
2632-
between two points. These are mainly used with
2633-
:class:`FancyArrowPatch`.
2628+
between two points. These are mainly used with `FancyArrowPatch`.
26342629
26352630
A connectionstyle object can be either created as::
26362631
@@ -3071,9 +3066,9 @@ def _point_along_a_line(x0, y0, x1, y1, d):
30713066

30723067
class ArrowStyle(_Style):
30733068
"""
3074-
:class:`ArrowStyle` is a container class which defines several
3069+
`ArrowStyle` is a container class which defines several
30753070
arrowstyle classes, which is used to create an arrow path along a
3076-
given path. These are mainly used with :class:`FancyArrowPatch`.
3071+
given path. These are mainly used with `FancyArrowPatch`.
30773072
30783073
A arrowstyle object can be either created as::
30793074
@@ -3099,7 +3094,7 @@ class ArrowStyle(_Style):
30993094
and it returns a tuple of a `.Path` instance and a boolean
31003095
value. *path* is a `.Path` instance along which the arrow
31013096
will be drawn. *mutation_size* and *aspect_ratio* have the same
3102-
meaning as in :class:`BoxStyle`. *linewidth* is a line width to be
3097+
meaning as in `BoxStyle`. *linewidth* is a line width to be
31033098
stroked. This is meant to be used to correct the location of the
31043099
head so that it does not overshoot the destination point, but not all
31053100
classes support it.
@@ -3854,7 +3849,7 @@ def transmute(self, path, mutation_size, linewidth):
38543849

38553850
class FancyArrowPatch(Patch):
38563851
"""
3857-
A fancy arrow patch. It draws an arrow using the :class:`ArrowStyle`.
3852+
A fancy arrow patch. It draws an arrow using the `ArrowStyle`.
38583853
38593854
The head and tail positions are fixed at the specified start and end points
38603855
of the arrow, but the size and shape (in display coordinates) of the arrow
@@ -3906,12 +3901,11 @@ def __init__(self, posA=None, posB=None,
39063901
*patchB*, *shrinkA*, and *shrinkB* are ignored.
39073902
39083903
arrowstyle : str or `.ArrowStyle`, default: 'simple'
3909-
Describes how the fancy arrow will be
3910-
drawn. It can be string of the available arrowstyle names,
3911-
with optional comma-separated attributes, or an
3912-
:class:`ArrowStyle` instance. The optional attributes are meant to
3913-
be scaled with the *mutation_scale*. The following arrow styles are
3914-
available:
3904+
The `.ArrowStyle` with which the fancy arrow is drawn. If a
3905+
string, it should be one of the available arrowstyle names, with
3906+
optional comma-separated attributes. The optional attributes are
3907+
meant to be scaled with the *mutation_scale*. The following arrow
3908+
styles are available:
39153909
39163910
%(AvailableArrowstyles)s
39173911
@@ -3920,19 +3914,18 @@ def __init__(self, posA=None, posB=None,
39203914
39213915
connectionstyle : str or `.ConnectionStyle` or None, optional, \
39223916
default: 'arc3'
3923-
Describes how *posA* and *posB* are connected. It can be an
3924-
instance of the :class:`ConnectionStyle` class or a string of the
3925-
connectionstyle name, with optional comma-separated attributes. The
3926-
following connection styles are available:
3917+
The `.ConnectionStyle` with which *posA* and *posB* are connected.
3918+
If a string, it should be one of the available connectionstyle
3919+
names, with optional comma-separated attributes. The following
3920+
connection styles are available:
39273921
39283922
%(AvailableConnectorstyles)s
39293923
39303924
connector
39313925
Ignored.
39323926
39333927
patchA, patchB : `.Patch`, default: None
3934-
Head and tail patch respectively. :class:`matplotlib.patch.Patch`
3935-
instance.
3928+
Head and tail patch respectively.
39363929
39373930
shrinkA, shrinkB : float, default: 2
39383931
Shrinking factor of the tail and head of the arrow respectively.
@@ -4100,9 +4093,7 @@ def set_connectionstyle(self, connectionstyle, **kw):
41004093
self.stale = True
41014094

41024095
def get_connectionstyle(self):
4103-
"""
4104-
Return the :class:`ConnectionStyle` instance.
4105-
"""
4096+
"""Return the `ConnectionStyle` used."""
41064097
return self._connector
41074098

41084099
def set_arrowstyle(self, arrowstyle=None, **kw):
@@ -4244,10 +4235,8 @@ def draw(self, renderer):
42444235

42454236

42464237
class ConnectionPatch(FancyArrowPatch):
4247-
"""
4248-
A :class:`~matplotlib.patches.ConnectionPatch` class is to make
4249-
connecting lines between two points (possibly in different axes).
4250-
"""
4238+
"""A patch that connects two points (possibly in different axes)."""
4239+
42514240
def __str__(self):
42524241
return "ConnectionPatch((%g, %g), (%g, %g))" % \
42534242
(self.xy1[0], self.xy1[1], self.xy2[0], self.xy2[1])
@@ -4284,7 +4273,7 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
42844273
shrinkB default is 2 points
42854274
mutation_scale default is text size (in points)
42864275
mutation_aspect default is 1.
4287-
? any key for :class:`matplotlib.patches.PathPatch`
4276+
? any key for `matplotlib.patches.PathPatch`
42884277
=============== ======================================================
42894278
42904279
*coordsA* and *coordsB* are strings that indicate the
@@ -4314,12 +4303,10 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
43144303
43154304
.. note::
43164305
4317-
Using :class:`~matplotlib.patches.ConnectionPatch` across
4318-
two :class:`~matplotlib.axes.Axes` instances is not
4319-
directly compatible with :doc:`constrained layout
4320-
</tutorials/intermediate/constrainedlayout_guide>`. Add the
4321-
artist directly to the :class:`~matplotlib.figure.Figure`
4322-
instead of adding it to a specific Axes.
4306+
Using `ConnectionPatch` across two `~.axes.Axes` instances
4307+
is not directly compatible with :doc:`constrained layout
4308+
</tutorials/intermediate/constrainedlayout_guide>`. Add the artist
4309+
directly to the `.Figure` instead of adding it to a specific Axes.
43234310
43244311
.. code-block:: default
43254312

0 commit comments

Comments
 (0)