Beispiel #1
0
 def graphics_array(self, ncols=3):
     """
     Return a graphics array with the given number of columns with plots
     of the frames of this animation.
     
     EXAMPLES::
     
         sage: E = EllipticCurve('37a')
         sage: v = [E.change_ring(GF(p)).plot(pointsize=30) for p in [97, 101, 103, 107]]
         sage: a = animate(v, xmin=0, ymin=0)
         sage: a
         Animation with 4 frames
         sage: a.show()        # optional -- ImageMagick
     
     ::
     
         sage: g = a.graphics_array()
         sage: print g
         Graphics Array of size 1 x 3
         sage: g.show(figsize=[4,1]) # optional
     
     ::
     
         sage: g = a.graphics_array(ncols=2)
         sage: print g
         Graphics Array of size 2 x 2
         sage: g.show('sage.png')         # optional
     """
     n = len(self.__frames)
     ncols = int(ncols)
     return plot.graphics_array(self.__frames, int(n/ncols),  ncols)
Beispiel #2
0
 def graphics_array(self, ncols=3):
     """
     Return a graphics array with the given number of columns with plots
     of the frames of this animation.
     
     EXAMPLES::
     
         sage: E = EllipticCurve('37a')
         sage: v = [E.change_ring(GF(p)).plot(pointsize=30) for p in [97, 101, 103, 107]]
         sage: a = animate(v, xmin=0, ymin=0)
         sage: a
         Animation with 4 frames
         sage: a.show()        # optional -- ImageMagick
     
     ::
     
         sage: g = a.graphics_array()
         sage: print g
         Graphics Array of size 1 x 3
         sage: g.show(figsize=[4,1]) # optional
     
     ::
     
         sage: g = a.graphics_array(ncols=2)
         sage: print g
         Graphics Array of size 2 x 2
         sage: g.show('sage.png')         # optional
     """
     n = len(self.__frames)
     ncols = int(ncols)
     return plot.graphics_array(self.__frames, int(n/ncols),  ncols)
Beispiel #3
0
    def graphics_array(self, ncols=3):
        r"""
        Return a :class:`sage.plot.graphics.GraphicsArray` with plots of the
        frames of this animation, using the given number of columns.
        The frames must be acceptable inputs for
        :class:`sage.plot.graphics.GraphicsArray`.


        EXAMPLES::

            sage: E = EllipticCurve('37a')
            sage: v = [E.change_ring(GF(p)).plot(pointsize=30) for p in [97, 101, 103, 107]]
            sage: a = animate(v, xmin=0, ymin=0)
            sage: a
            Animation with 4 frames
            sage: a.show() # optional -- ImageMagick

        Modify the default arrangement of array::

            sage: g = a.graphics_array(); print g
            Graphics Array of size 2 x 3
            sage: g.show(figsize=[4,1]) # optional

        Specify different arrangement of array and save with different file name::

            sage: g = a.graphics_array(ncols=2); print g
            Graphics Array of size 2 x 2
            sage: f = tmp_filename(ext='.png')
            sage: g.show(f) # optional

        Frames can be specified as a generator too; it is internally converted to a list::

            sage: t = var('t')
            sage: b = animate((plot(sin(c*pi*t)) for c in sxrange(1,2,.2)))
            sage: g = b.graphics_array(); print g
            Graphics Array of size 2 x 3
            sage: g.show() # optional
        """
        ncols = int(ncols)
        frame_list = list(self._frames)
        n = len(frame_list)
        nrows, rem = divmod(n,ncols)
        if rem > 0:
            nrows += 1
        return plot.graphics_array(frame_list, nrows,  ncols)