MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / iter_segments

Method iter_segments

lib/matplotlib/path.py:366–430  ·  view source on GitHub ↗

Iterate over all curve segments in the path. Each iteration returns a pair ``(vertices, code)``, where ``vertices`` is a sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code. Additionally, this method can provide a number of standard cleanups and

(self, transform=None, remove_nans=True, clip=None,
                      snap=False, stroke_width=1.0, simplify=None,
                      curves=True, sketch=None)

Source from the content-addressed store, hash-verified

364 return len(self.vertices)
365
366 def iter_segments(self, transform=None, remove_nans=True, clip=None,
367 snap=False, stroke_width=1.0, simplify=None,
368 curves=True, sketch=None):
369 """
370 Iterate over all curve segments in the path.
371
372 Each iteration returns a pair ``(vertices, code)``, where ``vertices``
373 is a sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code.
374
375 Additionally, this method can provide a number of standard cleanups and
376 conversions to the path.
377
378 Parameters
379 ----------
380 transform : None or :class:`~matplotlib.transforms.Transform`
381 If not None, the given affine transformation will be applied to the
382 path.
383 remove_nans : bool, optional
384 Whether to remove all NaNs from the path and skip over them using
385 MOVETO commands.
386 clip : None or (float, float, float, float), optional
387 If not None, must be a four-tuple (x1, y1, x2, y2)
388 defining a rectangle in which to clip the path.
389 snap : None or bool, optional
390 If True, snap all nodes to pixels; if False, don't snap them.
391 If None, snap if the path contains only segments
392 parallel to the x or y axes, and no more than 1024 of them.
393 stroke_width : float, optional
394 The width of the stroke being drawn (used for path snapping).
395 simplify : None or bool, optional
396 Whether to simplify the path by removing vertices
397 that do not affect its appearance. If None, use the
398 :attr:`should_simplify` attribute. See also :rc:`path.simplify`
399 and :rc:`path.simplify_threshold`.
400 curves : bool, optional
401 If True, curve segments will be returned as curve segments.
402 If False, all curves will be converted to line segments.
403 sketch : None or sequence, optional
404 If not None, must be a 3-tuple of the form
405 (scale, length, randomness), representing the sketch parameters.
406 """
407 if not len(self):
408 return
409
410 cleaned = self.cleaned(transform=transform,
411 remove_nans=remove_nans, clip=clip,
412 snap=snap, stroke_width=stroke_width,
413 simplify=simplify, curves=curves,
414 sketch=sketch)
415
416 # Cache these object lookups for performance in the loop.
417 NUM_VERTICES_FOR_CODE = self.NUM_VERTICES_FOR_CODE
418 STOP = self.STOP
419
420 vertices = iter(cleaned.vertices)
421 codes = iter(cleaned.codes)
422 for curr_vertices, code in zip(vertices, codes):
423 if code == STOP:

Callers 15

iter_bezierMethod · 0.95
test_start_with_movetoFunction · 0.95
test_clipping_fullFunction · 0.95
_path_to_3d_segmentFunction · 0.80
split_path_inoutFunction · 0.80
get_segmentsMethod · 0.80
draw_markersMethod · 0.80
_append_pathFunction · 0.80
draw_markersMethod · 0.80

Calls 1

cleanedMethod · 0.95

Tested by 4

test_start_with_movetoFunction · 0.76
test_clipping_fullFunction · 0.76
test_customcellFunction · 0.64
test_clipping_of_logFunction · 0.64