Пример #1
0
    def write_body(self):
        try:
            from matplotlib.path import Path
        except ImportError:
            Path = None
            from matplotlib.patches import Circle, Polygon
        else:
            from matplotlib.patches import Circle, PathPatch

        indices = self.X[:, 2].argsort()
        for a in indices:
            xy = self.X[a, :2]
            if a < self.natoms:
                r = self.d[a] / 2
                if ((xy[1] + r > 0) and (xy[1] - r < self.h) and
                    (xy[0] + r > 0) and (xy[0] - r < self.w)):
                    circle = Circle(xy, r, facecolor=self.colors[a])
                    circle.draw(self.renderer)
            else:
                a -= self.natoms
                c = self.T[a]
                if c != -1:
                    hxy = self.D[c]
                    if Path is None:
                        line = Polygon((xy + hxy, xy - hxy))
                    else:
                        line = PathPatch(Path((xy + hxy, xy - hxy)))
                    line.draw(self.renderer)
Пример #2
0
 def draw(self, renderer):
     x3d, y3d, z3d = self._verts3d
     x, y, z = proj3d.proj_transform(x3d, y3d, z3d, renderer.M)
     self.center = x, y
     Circle.draw(self, renderer)