def _create_patch(self): """Creates a matplotlib polygon patch from the Shape points. This is used when making 2d images of the Shape object. :raises ValueError: No points defined for the Shape :return: a plotable polygon shape :rtype: Matplotlib object patch """ if self.points is None: ValueError("No points defined for", self) patches = [] xylist = [] for x1, z1 in zip([row[0] for row in self.points], [row[1] for row in self.points]): xylist.append([x1, z1]) polygon = Polygon(xylist, closed=True) patches.append(polygon) p = PatchCollection(patches) if self.color is not None: p.set_facecolor(self.color) p.set_color(self.color) p.color = self.color p.edgecolor = self.color # checks to see if an alpha value is provided in the color if len(self.color) == 4: p.set_alpha = self.color[-1] self.patch = p return p
def _create_patch(self): """Creates a matplotlib polygon patch from the Shape points. This is used when making 2d images of the Shape object. Raises: ValueError: No points defined for the Shape Returns: Matplotlib object patch: a plotable polygon shape """ if self.points is None: raise ValueError("No points defined for", self) patches = [] xylist = [] for point in self.points: xylist.append([point[0], point[1]]) polygon = Polygon(xylist, closed=True) patches.append(polygon) patch = PatchCollection(patches) if self.color is not None: patch.set_facecolor(self.color) patch.set_color(self.color) patch.color = self.color patch.edgecolor = self.color # checks to see if an alpha value is provided in the color if len(self.color) == 4: patch.set_alpha = self.color[-1] self.patch = patch return patch
def _create_patch(self): """Creates a matplotlib polygon patch from the Shape points. This is used when making 2d images of the Shape object. Raises: ValueError: No points defined for the Shape Returns: Matplotlib object patch: a plotable polygon shape """ if self.points is None: raise ValueError("No points defined for", self) patches = [] edges = facet_wire(wire=self.wire, facet_splines=True, facet_circles=True) fpoints = [] for edge in edges: for vertice in edge.Vertices(): fpoints.append((vertice.X, vertice.Z)) polygon = Polygon(fpoints, closed=True) patches.append(polygon) patch = PatchCollection(patches) if self.color is not None: patch.set_facecolor(self.color) patch.set_color(self.color) patch.color = self.color patch.edgecolor = self.color # checks to see if an alpha value is provided in the color if len(self.color) == 4: patch.set_alpha = self.color[-1] self.patch = patch return patch