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

Skip to content

Commit 171f055

Browse files
authored
Merge pull request #20587 from tacaswell/auto-backport-of-pr-20584-on-v3.4.x
Backport PR #20584: FIX: do not simplify path in LineCollection.get_s…
2 parents ad27c9e + 3adeb00 commit 171f055

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/collections.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,14 @@ def get_segments(self):
14941494
segments = []
14951495

14961496
for path in self._paths:
1497-
vertices = [vertex for vertex, _ in path.iter_segments()]
1497+
vertices = [
1498+
vertex
1499+
for vertex, _
1500+
# Never simplify here, we want to get the data-space values
1501+
# back and there in no way to know the "right" simplification
1502+
# threshold so never try.
1503+
in path.iter_segments(simplify=False)
1504+
]
14981505
vertices = np.asarray(vertices)
14991506
segments.append(vertices)
15001507

lib/matplotlib/tests/test_collections.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,3 +868,12 @@ def test_array_wrong_dimensions():
868868
pc = plt.pcolormesh(z)
869869
pc.set_array(z) # 2D is OK for Quadmesh
870870
pc.update_scalarmappable()
871+
872+
873+
def test_get_segments():
874+
segments = np.tile(np.linspace(0, 1, 256), (2, 1)).T
875+
lc = LineCollection([segments])
876+
877+
readback, = lc.get_segments()
878+
# these should comeback un-changed!
879+
assert np.all(segments == readback)

0 commit comments

Comments
 (0)