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

Method interpolated

lib/matplotlib/path.py:688–726  ·  view source on GitHub ↗

Return a new path with each segment divided into *steps* parts. Codes other than `LINETO`, `MOVETO`, and `CLOSEPOLY` are not handled correctly. Parameters ---------- steps : int The number of segments in the new path for each in the original.

(self, steps)

Source from the content-addressed store, hash-verified

686 self, bbox.x0, bbox.y0, bbox.x1, bbox.y1, filled)
687
688 def interpolated(self, steps):
689 """
690 Return a new path with each segment divided into *steps* parts.
691
692 Codes other than `LINETO`, `MOVETO`, and `CLOSEPOLY` are not handled correctly.
693
694 Parameters
695 ----------
696 steps : int
697 The number of segments in the new path for each in the original.
698
699 Returns
700 -------
701 Path
702 The interpolated path.
703 """
704 if steps == 1 or len(self) == 0:
705 return self
706
707 if self.codes is not None and self.MOVETO in self.codes[1:]:
708 return self.make_compound_path(
709 *(p.interpolated(steps) for p in self._iter_connected_components()))
710
711 if self.codes is not None and self.CLOSEPOLY in self.codes and not np.all(
712 self.vertices[self.codes == self.CLOSEPOLY] == self.vertices[0]):
713 vertices = self.vertices.copy()
714 vertices[self.codes == self.CLOSEPOLY] = vertices[0]
715 else:
716 vertices = self.vertices
717
718 vertices = simple_linear_interpolation(vertices, steps)
719 codes = self.codes
720 if codes is not None:
721 new_codes = np.full((len(codes) - 1) * steps + 1, Path.LINETO,
722 dtype=self.code_type)
723 new_codes[0::steps] = codes
724 else:
725 new_codes = None
726 return Path(vertices, new_codes)
727
728 def to_polygons(self, transform=None, width=0, height=0, closed_only=True):
729 """

Calls 5

make_compound_pathMethod · 0.95
PathClass · 0.85
copyMethod · 0.45

Tested by 5

test_interpolated_movetoFunction · 0.76
transform_pathMethod · 0.64