8000 Merge pull request #845 from mdboom/get_path_collection_extents · matplotlib/matplotlib@0e9a04c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e9a04c

Browse files
committed
Merge pull request #845 from mdboom/get_path_collection_extents
doc/implementation mismatch for path.get_path_collection_extents()
2 parents 1c33830 + 7b7b84a commit 0e9a04c

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

lib/matplotlib/path.py

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,53 @@ def hatch(cls, hatchpattern, density=6):
710710
return hatch_path
711711

712712
_get_path_collection_extents = get_path_collection_extents
713-
def get_path_collection_extents(*args):
713+
def get_path_collection_extents(
714+
master_transform, paths, transforms, offsets, offset_transform):
714715
"""
715-
Given a sequence of :class:`Path` objects, returns the bounding
716-
box that encapsulates all of them.
716+
Given a sequence of :class:`Path` objects,
717+
:class:`~matplotlib.transforms.Transform` objects and offsets, as
718+
found in a :class:`~matplotlib.collections.PathCollection`,
719+
returns the bounding box that encapsulates all of them.
720+
721+
*master_transform* is a global transformation to apply to all paths
722+
723+
*paths* is a sequence of :class:`Path` instances.
724+
725+
*transforms* is a sequence of
726+
:class:`~matplotlib.transforms.Affine2D` instances.
727+
728+
*offsets* is a sequence of (x, y) offsets (or an Nx2 array)
729+
730+
*offset_transform* is a :class:`~matplotlib.transforms.Affine2D`
731+
to apply to the offsets before applying the offset to the path.
732+
733+
The way that *paths*, *transforms* and *offsets* are combined
734+
follows the same method as for collections. Each is iterated over
735+
independently, so if you have 3 paths, 2 transforms and 1 offset,
736+
their combinations are as follows:
737+
738+
(A, A, A), (B, B, A), (C, A, A)
717739
"""
718740
from transforms import Bbox
719-
if len(args[1]) == 0:
741+
if len(paths) == 0:
742+
raise ValueError("No paths provided")
743+
return Bbox.from_extents(*_get_path_collection_extents(
744+
master_transform, paths, transforms, offsets, offset_transform))
745+
746+
def get_paths_extents(paths, transforms=[]):
747+
"""
748+
Given a sequence of :class:`Path` objects and optional
749+
:class:`~matplotlib.transforms.Transform` objects, returns the
750+
bounding box that encapsulates all of them.
751+
752+
*paths* is a sequence of :class:`Path` instances.
753+
754+
*transforms* is an optional sequence of
755+
:class:`~matplotlib.transforms.Affine2D` instances to apply to
756+
each path.
757+
"""
758+
from transforms import Bbox, Affine2D
759+
if len(paths) == 0:
720760
raise ValueError("No paths provided")
721-
return Bbox.from_extents(*_get_path_collection_extents(*args))
761+
return Bbox.from_extents(*_get_path_collection_extents(
762+
Affine2D(), paths, transforms, [], Affine2D()))

0 commit comments

Comments
 (0)
0