Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,14 @@ def get_segments(self):
segments = []

for path in self._paths:
vertices = [vertex for vertex, _ in path.iter_segments()]
vertices = [
vertex
for vertex, _
# Never simplify here, we want to get the data-space values
# back and there in no way to know the "right" simplification
# threshold so never try.
in path.iter_segments(simplify=False)
]
vertices = np.asarray(vertices)
segments.append(vertices)

Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,3 +1039,12 @@ def test_quadmesh_cursor_data():
x, y = ax.transData.transform([-1, 101])
event = MouseEvent('motion_notify_event', fig.canvas, x, y)
assert qm.get_cursor_data(event) is None


def test_get_segments():
segments = np.tile(np.linspace(0, 1, 256), (2, 1)).T
lc = LineCollection([segments])

readback, = lc.get_segments()
# these should comeback un-changed!
assert np.all(segments == readback)