Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b3e34c

Browse filesBrowse files
authored
Merge pull request #12849 from anntzer/pathdocs
Update docstrings in path.py, and small cleanups.
2 parents e0c9185 + b2b747f commit 7b3e34c
Copy full SHA for 7b3e34c

File tree

Expand file treeCollapse file tree

3 files changed

+61
-69
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+61
-69
lines changed
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``path.get_paths_extents`` is deprecated; use
5+
`~.path.get_path_collection_extents` instead.

‎lib/matplotlib/path.py

Copy file name to clipboardExpand all lines: lib/matplotlib/path.py
+55-68Lines changed: 55 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import numpy as np
1616

17-
from . import _path, rcParams
17+
from . import _path, cbook, rcParams
1818
from .cbook import _to_unmasked_float_array, simple_linear_interpolation
1919

2020

@@ -359,46 +359,41 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,
359359
snap=False, stroke_width=1.0, simplify=None,
360360
curves=True, sketch=None):
361361
"""
362-
Iterates over all of the curve segments in the path. Each
363-
iteration returns a 2-tuple (*vertices*, *code*), where
364-
*vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is
365-
one of the :class:`Path` codes.
362+
Iterates over all of the curve segments in the path. Each iteration
363+
returns a 2-tuple ``(vertices, code)``, where ``vertices`` is a
364+
sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code.
366365
367-
Additionally, this method can provide a number of standard
368-
cleanups and conversions to the path.
366+
Additionally, this method can provide a number of standard cleanups and
367+
conversions to the path.
369368
370369
Parameters
371370
----------
372-
transform : None or :class:`~matplotlib.transforms.Transform` instance
373-
If not None, the given affine transformation will
374-
be applied to the path.
375-
remove_nans : {False, True}, optional
376-
If True, will remove all NaNs from the path and
377-
insert MOVETO commands to skip over them.
378-
clip : None or sequence, optional
371+
transform : None or :class:`~matplotlib.transforms.Transform`
372+
If not None, the given affine transformation will be applied to the
373+
path.
374+
remove_nans : bool, optional
375+
Whether to remove all NaNs from the path and skip over them using
376+
MOVETO commands.
377+
clip : None or (float, float, float, float), optional
379378
If not None, must be a four-tuple (x1, y1, x2, y2)
380379
defining a rectangle in which to clip the path.
381380
snap : None or bool, optional
382-
If None, auto-snap to pixels, to reduce
383-
fuzziness of rectilinear lines. If True, force snapping, and
384-
if False, don't snap.
381+
If True, snap all nodes to pixels; if False, don't snap them.
382+
If None, perform snapping if the path contains only segments
383+
parallel to the x or y axes, and no more than 1024 of them.
385384
stroke_width : float, optional
386-
The width of the stroke being drawn. Needed
387-
as a hint for the snapping algorithm.
385+
The width of the stroke being drawn (used for path snapping).
388386
simplify : None or bool, optional
389-
If True, perform simplification, to remove
390-
vertices that do not affect the appearance of the path. If
391-
False, perform no simplification. If None, use the
392-
should_simplify member variable. See also the rcParams
393-
path.simplify and path.simplify_threshold.
394-
curves : {True, False}, optional
395-
If True, curve segments will be returned as curve
396-
segments. If False, all curves will be converted to line
397-
segments.
387+
Whether to simplify the path by removing vertices
388+
that do not affect its appearance. If None, use the
389+
:attr:`should_simplify` attribute. See also :rc:`path.simplify`
390+
and :rc:`path.simplify_threshold`.
391+
curves : bool, optional
392+
If True, curve segments will be returned as curve segments.
393+
If False, all curves will be converted to line segments.
398394
sketch : None or sequence, optional
399395
If not None, must be a 3-tuple of the form
400-
(scale, length, randomness), representing the sketch
401-
parameters.
396+
(scale, length, randomness), representing the sketch parameters.
402397
"""
403398
if not len(self):
404399
return
@@ -441,7 +436,6 @@ def cleaned(self, transform=None, remove_nans=False, clip=None,
441436
Returns
442437
-------
443438
Path instance with cleaned up vertices and codes.
444-
445439
"""
446440
vertices, codes = _path.cleanup_path(self, transform,
447441
remove_nans, clip,
@@ -621,8 +615,7 @@ def to_polygons(self, transform=None, width=0, height=0, closed_only=True):
621615
@classmethod
622616
def unit_rectangle(cls):
623617
"""
624-
Return a :class:`Path` instance of the unit rectangle
625-
from (0, 0) to (1, 1).
618+
Return a `Path` instance of the unit rectangle from (0, 0) to (1, 1).
626619
"""
627620
if cls._unit_rectangle is None:
628621
cls._unit_rectangle = \
@@ -706,7 +699,6 @@ def unit_circle(cls):
706699
Return the readonly :class:`Path` of the unit circle.
707700
708701
For most cases, :func:`Path.circle` will be what you want.
709-
710702
"""
711703
if cls._unit_circle is None:
712704
cls._unit_circle = cls.circle(center=(0, 0), radius=1,
@@ -716,7 +708,7 @@ def unit_circle(cls):
716708
@classmethod
717709
def circle(cls, center=(0., 0.), radius=1., readonly=False):
718710
"""
719-
Return a Path representing a circle of a given radius and center.
711+
Return a `Path` representing a circle of a given radius and center.
720712
721713
Parameters
722714
----------
@@ -730,13 +722,10 @@ def circle(cls, center=(0., 0.), radius=1., readonly=False):
730722
731723
Notes
732724
-----
733-
The circle is approximated using cubic Bezier curves. This
734-
uses 8 splines around the circle using the approach presented
735-
here:
725+
The circle is approximated using 8 cubic Bezier curves, as decribed in
736726
737727
Lancaster, Don. `Approximating a Circle or an Ellipse Using Four
738728
Bezier Cubic Splines <http://www.tinaja.com/glib/ellipse4.pdf>`_.
739-
740729
"""
741730
MAGIC = 0.2652031
742731
SQRTHALF = np.sqrt(0.5)
@@ -789,13 +778,9 @@ def circle(cls, center=(0., 0.), radius=1., readonly=False):
789778
@classmethod
790779
def unit_circle_righthalf(cls):
791780
"""
792-
Return a :class:`Path` of the right half
793-
of a unit circle. The circle is approximated using cubic Bezier
794-
curves. This uses 4 splines around the circle using the approach
795-
presented here:
781+
Return a `Path` of the right half of a unit circle.
796782
797-
Lancaster, Don. `Approximating a Circle or an Ellipse Using Four
798-
Bezier Cubic Splines <http://www.tinaja.com/glib/ellipse4.pdf>`_.
783+
See `Path.circle` for the reference on the approximation used.
799784
"""
800785
if cls._unit_circle_righthalf is None:
801786
MAGIC = 0.2652031
@@ -835,8 +820,8 @@ def unit_circle_righthalf(cls):
835820
@classmethod
836821
def arc(cls, theta1, theta2, n=None, is_wedge=False):
837822
"""
838-
Return an arc on the unit circle from angle
839-
*theta1* to angle *theta2* (in degrees).
823+
Return the unit circle arc from angles *theta1* to *theta2* (in
824+
degrees).
840825
841826
*theta2* is unwrapped to produce the shortest arc within 360 degrees.
842827
That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
@@ -914,8 +899,8 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
914899
@classmethod
915900
def wedge(cls, theta1, theta2, n=None):
916901
"""
917-
Return a wedge of the unit circle from angle
918-
*theta1* to angle *theta2* (in degrees).
902+
Return the unit circle wedge from angles *theta1* to *theta2* (in
903+
degrees).
919904
920905
*theta2* is unwrapped to produce the shortest wedge within 360 degrees.
921906
That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
@@ -924,6 +909,8 @@ def wedge(cls, theta1, theta2, n=None):
924909
If *n* is provided, it is the number of spline segments to make.
925910
If *n* is not provided, the number of spline segments is
926911
determined based on the delta between *theta1* and *theta2*.
912+
913+
See `Path.arc` for the reference on the approximation used.
927914
"""
928915
return cls.arc(theta1, theta2, n, True)
929916

@@ -957,26 +944,25 @@ def clip_to_bbox(self, bbox, inside=True):
957944

958945
def get_path_collection_extents(
959946
master_transform, paths, transforms, offsets, offset_transform):
960-
"""
961-
Given a sequence of :class:`Path` objects,
962-
:class:`~matplotlib.transforms.Transform` objects and offsets, as
963-
found in a :class:`~matplotlib.collections.PathCollection`,
964-
returns the bounding box that encapsulates all of them.
965-
966-
*master_transform* is a global transformation to apply to all paths
967-
968-
*paths* is a sequence of :class:`Path` instances.
969-
970-
*transforms* is a sequence of
971-
:class:`~matplotlib.transforms.Affine2D` instances.
972-
973-
*offsets* is a sequence of (x, y) offsets (or an Nx2 array)
974-
975-
*offset_transform* is a :class:`~matplotlib.transforms.Affine2D`
976-
to apply to the offsets before applying the offset to the path.
977-
947+
r"""
948+
Given a sequence of `Path`\s, `~.Transform`\s objects, and offsets, as
949+
found in a `~.PathCollection`, returns the bounding box that encapsulates
950+
all of them.
951+
952+
Parameters
953+
----------
954+
master_transform : `~.Transform`
955+
Global transformation applied to all paths.
956+
paths : list of `Path`
957+
transform : list of `~.Affine2D`
958+
offsets : (N, 2) array-like
959+
offset_transform : `~.Affine2D`
960+
Transform applied to the offsets before offsetting the path.
961+
962+
Notes
963+
-----
978964
The way that *paths*, *transforms* and *offsets* are combined
979-
follows the same method as for collections. Each is iterated over
965+
follows the same method as for collections: Each is iterated over
980966
independently, so if you have 3 paths, 2 transforms and 1 offset,
981967
their combinations are as follows:
982968
@@ -990,6 +976,7 @@ def get_path_collection_extents(
990976
offsets, offset_transform))
991977

992978

979+
@cbook.deprecated("3.1", alternative="get_paths_collection_extents")
993980
def get_paths_extents(paths, transforms=[]):
994981
"""
995982
Given a sequence of :class:`Path` objects and optional

‎src/path_converters.h

Copy file name to clipboardExpand all lines: src/path_converters.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class PathSnapper
484484
case agg::path_cmd_curve4:
485485
return false;
486486
case agg::path_cmd_line_to:
487-
if (!(fabs(x0 - x1) < 1e-4 || fabs(y0 - y1) < 1e-4)) {
487+
if (fabs(x0 - x1) >= 1e-4 && fabs(y0 - y1) >= 1e-4) {
488488
return false;
489489
}
490490
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.