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 cfff1bc

Browse filesBrowse files
committed
Merge pull request #17017 from jklymak/fix-blended-transform
FIX: force blended transforms with data to be in data space
1 parent 8ac76de commit cfff1bc
Copy full SHA for cfff1bc

File tree

Expand file treeCollapse file tree

2 files changed

+15
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-1
lines changed

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_collections.py
+14Lines changed: 14 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.