Skip to content

Commit fd09e5c

Browse files
authored
Merge pull request #17020 from jklymak/backport17017
Merge pull request #17017 from jklymak/fix-blended-transform
2 parents 8ac76de + cfff1bc commit fd09e5c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/matplotlib/collections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_datalim(self, transData):
221221
# get_path_collection_extents handles nan but not masked arrays
222222

223223
if len(paths) and len(offsets):
224-
if transform.contains_branch(transData):
224+
if any(transform.contains_branch_seperately(transData)):
225225
# collections that are just in data units (like quiver)
226226
# can properly have the axes limits set by their shape +
227227
# offset. LineCollections that have no offsets can

lib/matplotlib/tests/test_collections.py

+14
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,17 @@ def test_EventCollection_nosort():
718718
arr = np.array([3, 2, 1, 10])
719719
coll = EventCollection(arr)
720720
np.testing.assert_array_equal(arr, np.array([3, 2, 1, 10]))
721+
722+
723+
def test_blended_collection_autolim():
724+
a = [1, 2, 4]
725+
height = .2
726+
727+
xy_pairs = np.column_stack([np.repeat(a, 2), np.tile([0, height], len(a))])
728+
line_segs = xy_pairs.reshape([len(a), 2, 2])
729+
730+
f, ax = plt.subplots()
731+
trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
732+
ax.add_collection(LineCollection(line_segs, transform=trans))
733+
ax.autoscale_view(scalex=True, scaley=False)
734+
np.testing.assert_allclose(ax.get_xlim(), [1., 4.])

0 commit comments

Comments
 (0)