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

Skip to content

Commit e996212

Browse files
authored
Merge pull request #20584 from tacaswell/fix_linecollection_simplified_segments
FIX: do not simplify path in LineCollection.get_segments
2 parents 06141da + 5570642 commit e996212

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
@@ -1461,7 +1461,14 @@ def get_segments(self):
14611461
segments = []
14621462

14631463
for path in self._paths:
1464-
vertices = [vertex for vertex, _ in path.iter_segments()]
1464+
vertices = [
1465+
vertex
1466+
for vertex, _
1467+
# Never simplify here, we want to get the data-space values
1468+
# back and there in no way to know the "right" simplification
1469+
# threshold so never try.
1470+
in path.iter_segments(simplify=False)
1471+
]
14651472
vertices = np.asarray(vertices)
14661473
segments.append(vertices)
14671474

lib/matplotlib/tests/test_collections.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,3 +1039,12 @@ def test_quadmesh_cursor_data():
10391039
x, y = ax.transData.transform([-1, 101])
10401040
event = MouseEvent('motion_notify_event', fig.canvas, x, y)
10411041
assert qm.get_cursor_data(event) is None
1042+
1043+
1044+
def test_get_segments():
1045+
segments = np.tile(np.linspace(0, 1, 256), (2, 1)).T
1046+
lc = LineCollection([segments])
1047+
1048+
readback, = lc.get_segments()
1049+
# these should comeback un-changed!
1050+
assert np.all(segments == readback)

0 commit comments

Comments
 (0)