Python matplotlib.animation.ArtistAnimation() Examples

The following are code examples for showing how to use matplotlib.animation.ArtistAnimation(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: CoherentXrayImaging   Author: susannahammarberg   File: load_data_plot3Dpeak.py    (license) View Source Project 6 votes vote down vote up
def plot_summed_patterns_one_point(row,col):
    # sum the diffrtaction patterns in one point
    summed_point = 0
    for j in range(0,nbr_rotations):
        summed_point  = summed_point + list_Merlin[j][row][col].toarray()  
    plt.figure()
    plt.imshow(np.log10(summed_point), cmap = 'hot', interpolation = 'none')
    plt.axis('off')
    plt.colorbar()
    plt.title('masked diffraction patterns sum of one position in %d scans'%nbr_rotations)
#plot_summed_patterns_one_point(8,49)   #inser col and row you want to plot


#            # anim TABORT
#            im = plt.imshow(abs(objectFunc), animated=True, interpolation='none', extent=[0,6.837770297837617,0,6.825238081022181])
#            
#                    ims.append([im])
#                    ani = animation.ArtistAnimation(fig, ims, interval=1500, blit=True,repeat_delay=2000)
#                    plt.show()
# plot diffraction patterns merlin + pilK100 
Example 2
Project: BRATS   Author: ahmedhussein622   File: utility.py    (license) View Source Project 5 votes vote down vote up
def draw_MRI(image_3d_gray, interval = 50, repeat_delay=500):
    """
    draws a 3d image in time laps
    image_3d_gray : 3d numpy array of gray scale
    """
    fig = plt.figure()
    ims = []
    for i in range(image_3d_gray.shape[0]):
        im = plt.imshow(image_3d_gray[i], cmap = "Greys_r")
        ims.append([im])
        
    
    ani = animation.ArtistAnimation(fig, ims, interval=interval, blit=False, repeat_delay=repeat_delay) 
    plt.show() 
Example 3
Project: evolearn   Author: chadwcarlson   File: visualize.py    (license) View Source Project 5 votes vote down vote up
def animate(self):

        """animate function for actually generating figure from Animation instance.
        """

        ani = animation.ArtistAnimation(self.fig, self.frames, interval=self.interval, blit=self.blit, repeat_delay=self.repeat_delay)
        plt.axis('off')

        plt.show() 
Example 4
Project: gm-cml   Author: wangyida   File: gif.py    (license) View Source Project 4 votes vote down vote up
def build_gif(imgs, interval=0.1, dpi=72,
              save_gif=True, saveto='animation.gif',
              show_gif=False, cmap=None):
    """Take an array or list of images and create a GIF.

    Parameters
    ----------
    imgs : np.ndarray or list
        List of images to create a GIF of
    interval : float, optional
        Spacing in seconds between successive images.
    dpi : int, optional
        Dots per inch.
    save_gif : bool, optional
        Whether or not to save the GIF.
    saveto : str, optional
        Filename of GIF to save.
    show_gif : bool, optional
        Whether or not to render the GIF using plt.
    cmap : None, optional
        Optional colormap to apply to the images.

    Returns
    -------
    ani : matplotlib.animation.ArtistAnimation
        The artist animation from matplotlib.  Likely not useful.
    """
    imgs = np.asarray(imgs)
    h, w, *c = imgs[0].shape
    fig, ax = plt.subplots(figsize=(np.round(w / dpi), np.round(h / dpi)))
    fig.subplots_adjust(bottom=0)
    fig.subplots_adjust(top=1)
    fig.subplots_adjust(right=1)
    fig.subplots_adjust(left=0)
    ax.set_axis_off()

    if cmap is not None:
        axs = list(map(lambda x: [
            ax.imshow(x, cmap=cmap)], imgs))
    else:
        axs = list(map(lambda x: [
            ax.imshow(x)], imgs))

    ani = animation.ArtistAnimation(
        fig, axs, interval=interval, repeat_delay=0, blit=False)

    if save_gif:
        ani.save(saveto, writer='imagemagick', dpi=dpi)

    if show_gif:
        plt.show()

    return ani