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

Skip to content

Commit f8a9a49

Browse files
authored
Merge pull request #15903 from anntzer/nonaffine-transdata
Correctly handle non-affine transData in Collection.get_datalim.
2 parents 80877a0 + fbbc96f commit f8a9a49

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/matplotlib/collections.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ def get_datalim(self, transData):
209209

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

217219
if isinstance(offsets, np.ma.MaskedArray):
218220
offsets = offsets.filled(np.nan)
@@ -225,8 +227,8 @@ def get_datalim(self, transData):
225227
# offset. LineCollections that have no offsets can
226228
# also use this algorithm (like streamplot).
227229
result = mpath.get_path_collection_extents(
228-
transform.frozen(), paths, self.get_transforms(),
229-
offsets, transOffset.frozen())
230+
transform.get_affine(), paths, self.get_transforms(),
231+
offsets, transOffset.get_affine().frozen())
230232
return result.inverse_transformed(transData)
231233
if not self._offsetsNone:
232234
# this is for collections that have their paths (shapes)
@@ -235,7 +237,7 @@ def get_datalim(self, transData):
235237
# those shapes, so we just set the limits based on their
236238
# location.
237239
# Finish the transform:
238-
offsets = (transOffset +
240+
offsets = (transOffset.get_affine() +
239241
transData.inverted()).transform(offsets)
240242
offsets = np.ma.masked_invalid(offsets)
241243
if not offsets.mask.all():

0 commit comments

Comments
 (0)