Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ class Path:

These two arrays always have the same length in the first
dimension. For example, to represent a cubic curve, you must
provide three vertices and three ``CURVE4`` codes.
provide three vertices and three `CURVE4` codes.

The code types are:

- ``STOP`` : 1 vertex (ignored)
- `STOP` : 1 vertex (ignored)
A marker for the end of the entire path (currently not required and
ignored)

- ``MOVETO`` : 1 vertex
- `MOVETO` : 1 vertex
Pick up the pen and move to the given vertex.

- ``LINETO`` : 1 vertex
- `LINETO` : 1 vertex
Draw a line from the current position to the given vertex.

- ``CURVE3`` : 1 control point, 1 endpoint
- `CURVE3` : 1 control point, 1 endpoint
Draw a quadratic Bézier curve from the current position, with the given
control point, to the given end point.

- ``CURVE4`` : 2 control points, 1 endpoint
- `CURVE4` : 2 control points, 1 endpoint
Draw a cubic Bézier curve from the current position, with the given
control points, to the given end point.

- ``CLOSEPOLY`` : 1 vertex (ignored)
- `CLOSEPOLY` : 1 vertex (ignored)
Draw a line segment to the start point of the current polyline.

If *codes* is None, it is interpreted as a ``MOVETO`` followed by a series
of ``LINETO``.
If *codes* is None, it is interpreted as a `MOVETO` followed by a series
of `LINETO`.

Users of Path objects should not access the vertices and codes arrays
directly. Instead, they should use `iter_segments` or `cleaned` to get the
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1,
If *codes* is None and closed is True, vertices will be treated as
line segments of a closed polygon. Note that the last vertex will
then be ignored (as the corresponding code will be set to
CLOSEPOLY).
`CLOSEPOLY`).
readonly : bool, optional
Makes the path behave in an immutable way and sets the vertices
and codes as read-only arrays.
Expand Down Expand Up @@ -319,7 +319,7 @@ def make_compound_path_from_polys(cls, XY):
@classmethod
def make_compound_path(cls, *args):
r"""
Concatenate a list of `Path`\s into a single `.Path`, removing all `.STOP`\s.
Concatenate a list of `Path`\s into a single `Path`, removing all `STOP`\s.
"""
if not args:
return Path(np.empty([0, 2], dtype=np.float32))
Expand Down Expand Up @@ -412,7 +412,7 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,

def iter_bezier(self, **kwargs):
"""
Iterate over each Bézier curve (lines included) in a Path.
Iterate over each Bézier curve (lines included) in a `Path`.

Parameters
----------
Expand All @@ -421,15 +421,15 @@ def iter_bezier(self, **kwargs):

Yields
------
B : matplotlib.bezier.BezierSegment
B : `~matplotlib.bezier.BezierSegment`
The Bézier curves that make up the current path. Note in particular
that freestanding points are Bézier curves of order 0, and lines
are Bézier curves of order 1 (with two control points).
code : Path.code_type
code : `~matplotlib.path.Path.code_type`
The code describing what kind of curve is being returned.
Path.MOVETO, Path.LINETO, Path.CURVE3, Path.CURVE4 correspond to
`MOVETO`, `LINETO`, `CURVE3`, and `CURVE4` correspond to
Bézier curves with 1, 2, 3, and 4 control points (respectively).
Path.CLOSEPOLY is a Path.LINETO with the control points correctly
`CLOSEPOLY` is a `LINETO` with the control points correctly
chosen based on the start/end points of the current stroke.
"""
first_vert = None
Expand Down Expand Up @@ -461,7 +461,7 @@ def cleaned(self, transform=None, remove_nans=False, clip=None,
*, simplify=False, curves=False,
stroke_width=1.0, snap=False, sketch=None):
"""
Return a new Path with vertices and codes cleaned according to the
Return a new `Path` with vertices and codes cleaned according to the
parameters.

See Also
Expand Down Expand Up @@ -494,14 +494,14 @@ def contains_point(self, point, transform=None, radius=0.0):
Return whether the area enclosed by the path contains the given point.

The path is always treated as closed; i.e. if the last code is not
CLOSEPOLY an implicit segment connecting the last vertex to the first
`CLOSEPOLY` an implicit segment connecting the last vertex to the first
vertex is assumed.

Parameters
----------
point : (float, float)
The point (x, y) to check.
transform : `matplotlib.transforms.Transform`, optional
transform : `~matplotlib.transforms.Transform`, optional
If not ``None``, *point* will be compared to ``self`` transformed
by *transform*; i.e. for a correct check, *transform* should
transform the path into the coordinate system of *point*.
Expand Down Expand Up @@ -544,14 +544,14 @@ def contains_points(self, points, transform=None, radius=0.0):
Return whether the area enclosed by the path contains the given points.

The path is always treated as closed; i.e. if the last code is not
CLOSEPOLY an implicit segment connecting the last vertex to the first
`CLOSEPOLY` an implicit segment connecting the last vertex to the first
vertex is assumed.

Parameters
----------
points : (N, 2) array
The points to check. Columns contain x and y values.
transform : `matplotlib.transforms.Transform`, optional
transform : `~matplotlib.transforms.Transform`, optional
If not ``None``, *points* will be compared to ``self`` transformed
by *transform*; i.e. for a correct check, *transform* should
transform the path into the coordinate system of *points*.
Expand Down Expand Up @@ -600,7 +600,7 @@ def get_extents(self, transform=None, **kwargs):

Parameters
----------
transform : matplotlib.transforms.Transform, optional
transform : `~matplotlib.transforms.Transform`, optional
Transform to apply to path before computing extents, if any.
**kwargs
Forwarded to `.iter_bezier`.
Expand Down Expand Up @@ -658,9 +658,9 @@ def intersects_bbox(self, bbox, filled=True):

def interpolated(self, steps):
"""
Return a new path resampled to length N x steps.
Return a new path resampled to length N x *steps*.

Codes other than LINETO are not handled correctly.
Codes other than `LINETO` are not handled correctly.
"""
if steps == 1:
return self
Expand All @@ -679,7 +679,7 @@ def to_polygons(self, transform=None, width=0, height=0, closed_only=True):
"""
Convert this path to a list of polygons or polylines. Each
polygon/polyline is an (N, 2) array of vertices. In other words,
each polygon has no ``MOVETO`` instructions or curves. This
each polygon has no `MOVETO` instructions or curves. This
is useful for displaying in backends that do not support
compound paths or Bézier curves.

Expand Down Expand Up @@ -1016,7 +1016,7 @@ def wedge(cls, theta1, theta2, n=None):
@lru_cache(8)
def hatch(hatchpattern, density=6):
"""
Given a hatch specifier, *hatchpattern*, generates a Path that
Given a hatch specifier, *hatchpattern*, generates a `Path` that
can be used in a repeated hatching pattern. *density* is the
number of lines per unit square.
"""
Expand Down Expand Up @@ -1048,7 +1048,7 @@ def get_path_collection_extents(

Parameters
----------
master_transform : `.Transform`
master_transform : `~matplotlib.transforms.Transform`
Global transformation applied to all paths.
paths : list of `Path`
transforms : list of `~matplotlib.transforms.Affine2DBase`
Expand Down