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

Skip to content

Commit 98dff87

Browse files
authored
Merge pull request #17017 from jklymak/fix-blended-transform
FIX: force blended transforms with data to be in data space
2 parents a451e2c + ba075b1 commit 98dff87

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_datalim(self, transData):
219219
# get_path_collection_extents handles nan but not masked arrays
220220

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

lib/matplotlib/tests/test_collections.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,17 @@ def test_collection_set_verts_array():
616616
for ap, lp in zip(col_arr._paths, col_list._paths):
617617
assert np.array_equal(ap._vertices, lp._vertices)
618618
assert np.array_equal(ap._codes, lp._codes)
619+
620+
621+
def test_blended_collection_autolim():
622+
a = [1, 2, 4]
623+
height = .2
624+
625+
xy_pairs = np.column_stack([np.repeat(a, 2), np.tile([0, height], len(a))])
626+
line_segs = xy_pairs.reshape([len(a), 2, 2])
627+
628+
f, ax = plt.subplots()
629+
trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
630+
ax.add_collection(LineCollection(line_segs, transform=trans))
631+
ax.autoscale_view(scalex=True, scaley=False)
632+
np.testing.assert_allclose(ax.get_xlim(), [1., 4.])

0 commit comments

Comments
 (0)