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 2655bba

Browse filesBrowse files
authored
Merge pull request #17250 from jklymak/auto-backport-of-pr-17206-on-v3.2.x
Merge pull request #17206 from jklymak/fix-bypass-inverse-collection
2 parents e89e205 + ebab39c commit 2655bba
Copy full SHA for 2655bba

File tree

Expand file treeCollapse file tree

2 files changed

+13
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-7
lines changed

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ def get_datalim(self, transData):
213213
# we may have transform.contains_branch(transData) but not
214214
# transforms.get_affine().contains_branch(transData). But later,
215215
# be careful to only apply the affine part that remains.
216-
if not transOffset.is_affine:
217-
offsets = transOffset.transform_non_affine(offsets)
218216

219217
if isinstance(offsets, np.ma.MaskedArray):
220218
offsets = offsets.filled(np.nan)
@@ -228,17 +226,18 @@ def get_datalim(self, transData):
228226
# also use this algorithm (like streamplot).
229227
result = mpath.get_path_collection_extents(
230228
transform.get_affine(), paths, self.get_transforms(),
231-
offsets, transOffset.get_affine().frozen())
232-
return result.inverse_transformed(transData)
229+
transOffset.transform_non_affine(offsets),
230+
transOffset.get_affine().frozen())
231+
return result.transformed(transData.inverted())
233232
if not self._offsetsNone:
234233
# this is for collections that have their paths (shapes)
235234
# in physical, axes-relative, or figure-relative units
236235
# (i.e. like scatter). We can't uniquely set limits based on
237236
# those shapes, so we just set the limits based on their
238237
# location.
239-
# Finish the transform:
240-
offsets = (transOffset.get_affine() +
241-
transData.inverted()).transform(offsets)
238+
239+
offsets = (transOffset - transData).transform(offsets)
240+
# note A-B means A B^{-1}
242241
offsets = np.ma.masked_invalid(offsets)
243242
if not offsets.mask.all():
244243
points = np.row_stack((offsets.min(axis=0),

‎lib/matplotlib/tests/test_collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_collections.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,10 @@ def test_blended_collection_autolim():
732732
ax.add_collection(LineCollection(line_segs, transform=trans))
733733
ax.autoscale_view(scalex=True, scaley=False)
734734
np.testing.assert_allclose(ax.get_xlim(), [1., 4.])
735+
736+
737+
def test_singleton_autolim():
738+
fig, ax = plt.subplots()
739+
ax.scatter(0, 0)
740+
np.testing.assert_allclose(ax.get_ylim(), [-0.06, 0.06])
741+
np.testing.assert_allclose(ax.get_xlim(), [-0.06, 0.06])

0 commit comments

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