Example #1
0
 def draw(self):
     # add faces
     polygons = []
     for key in self.mesh.faces():
         polygons.append({
             'points': self.mesh.face_coordinates(key),
             'facecolor': '#eeeeee',
             'edgecolor': '#cccccc'
         })
     collection = draw_xpolygons_xy(polygons, self.plotter.axes)
     self._mpl_facecollection = collection
     # add vertices
     points = []
     for key in self.mesh.vertices():
         points.append({
             'pos': self.mesh.vertex_attributes(key, 'xy'),
             'radius': 0.1,
             'text': None,
             'facecolor': '#ffffff',
             'edgecolor': '#000000',
             'edgewidth': 0.5,
             'textcolor': '#000000',
             'fontsize': 6
         })
     collection = draw_xpoints_xy(points, self.plotter.axes)
     self._mpl_vertexcollection = collection
     # add edges
     lines = []
     for key in self.mesh.edges():
         u, v = key
         lines.append({
             'start': self.mesh.vertex_attributes(u, 'xy'),
             'end': self.mesh.vertex_attributes(v, 'xy'),
             'width': 1.0,
             'color': (255, 0, 0)
         })
     collection = draw_xlines_xy(lines, self.plotter.axes)
     self._mpl_edgecollection = collection
Example #2
0
    def draw_polygons(self, polygons):
        """Draws polygons on a 2D plot.

        Parameters
        ----------
        polygons : list of dict
            List of dictionaries containing the polygon properties.
            The following properties can be specified in the dict.

            * points (list): XY(Z) coordinates of the polygon vertices.
            * text (str, optional): The text of the label. Default is ``None``.
            * textcolor (rgb tuple or hex string, optional): Color of the label text. Default is black.
            * fontsize (int, optional): The size of the font of the label text. Default is ```12``.
            * facecolor (rgb tuple or hex string, optional): Color of the polygon face. Default is white.
            * edgecolor (rgb tuple or hex string, optional): Color of the edge of the polygon. Default is black.
            * edgewidth (float): Width of the polygon edge. Default is ``1.0``.

        Returns
        -------
        object
            The matplotlib polygon collection object.

        """
        return draw_xpolygons_xy(polygons, self.axes)