def save(filename, n_frames=1, axis=np.array([0.,0.,1.]), clf=True, **kwargs):
        """Save frames from the viewer out to a file.

        Parameters
        ----------
        filename : str
            The filename in which to save the output image. If more than one frame,
            should have extension .gif.
        n_frames : int
            Number of frames to render. If more than one, the scene will animate.
        axis : (3,) float or None
            If present, the animation will rotate about the given axis in world coordinates.
            Otherwise, the animation will rotate in azimuth.
        clf : bool
            If true, the Visualizer is cleared after rendering the figure.
        kwargs : dict
            Other keyword arguments for the SceneViewer instance.
        """
        if n_frames >1 and os.path.splitext(filename)[1] != '.gif':
            raise ValueError('Expected .gif file for multiple-frame save.')
        v = SceneViewer(Visualizer3D._scene,
                        size=Visualizer3D._init_size,
                        animate=(n_frames > 1),
                        animate_axis=axis,
                        max_frames=n_frames,
                        **kwargs)
        data = [m.data for m in v.saved_frames]
        if len(data) > 1:
            imageio.mimwrite(filename, data, fps=v._animate_rate, palettesize=128, subrectangles=True)
        else:
            imageio.imwrite(filename, data[0])

        if clf:
            Visualizer3D.clf()
Save frames from the viewer out to a file.

        Parameters
        ----------
        filename : str
            The filename in which to save the output image. If more than one frame,
            should have extension .gif.
        n_frames : int
            Number of frames to render. If more than one, the scene will animate.
        axis : (3,) float or None
            If present, the animation will rotate about the given axis in world coordinates.
            Otherwise, the animation will rotate in azimuth.
        clf : bool
            If true, the Visualizer is cleared after rendering the figure.
        kwargs : dict
            Other keyword arguments for the SceneViewer instance.