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

Skip to content

Backport PR #15903 on branch v3.2.x (Correctly handle non-affine transData in Collection.get_datalim.) #15915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
12 changes: 7 additions & 5 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ def get_datalim(self, transData):

if not transform.is_affine:
paths = [transform.transform_path_non_affine(p) for p in paths]
transform = transform.get_affine()
# Don't convert transform to transform.get_affine() here because
# we may have transform.contains_branch(transData) but not
# transforms.get_affine().contains_branch(transData). But later,
# be careful to only apply the affine part that remains.
if not transOffset.is_affine:
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()

if isinstance(offsets, np.ma.MaskedArray):
offsets = offsets.filled(np.nan)
Expand All @@ -225,8 +227,8 @@ def get_datalim(self, transData):
# offset. LineCollections that have no offsets can
# also use this algorithm (like streamplot).
result = mpath.get_path_collection_extents(
transform.frozen(), paths, self.get_transforms(),
offsets, transOffset.frozen())
transform.get_affine(), paths, self.get_transforms(),
offsets, transOffset.get_affine().frozen())
return result.inverse_transformed(transData)
if not self._offsetsNone:
# this is for collections that have their paths (shapes)
Expand All @@ -235,7 +237,7 @@ def get_datalim(self, transData):
# those shapes, so we just set the limits based on their
# location.
# Finish the transform:
offsets = (transOffset +
offsets = (transOffset.get_affine() +
transData.inverted()).transform(offsets)
offsets = np.ma.masked_invalid(offsets)
if not offsets.mask.all():
Expand Down