From faf58d54d7afc96cdf3cce839f233fca1a3da1d8 Mon Sep 17 00:00:00 2001 From: Todd Jennings Date: Tue, 8 Jan 2013 20:35:39 +0100 Subject: [PATCH] Add 'get_segments' method to the collections.LineCollection class --- lib/matplotlib/collections.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 1a0410be7ebb..bebe76ea706c 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -1008,6 +1008,16 @@ def set_segments(self, segments): set_verts = set_segments # for compatibility with PolyCollection set_paths = set_segments + def get_segments(self): + segments = [] + + for path in self._paths: + vertices = [vertex for vertex, _ in path.iter_segments()] + vertices = np.asarray(vertices) + segments.append(vertices) + + return segments + def _add_offsets(self, segs): offsets = self._uniform_offsets Nsegs = len(segs)