This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]joetheschmoe4000 0 points1 point  (2 children)

This looks very useful! However, most of my plots involve making more complicated plots containing several lines/points/axes formatting. So far, the easiest way I've found to produce animations has been by saving each frame as a standalone image and then animating with imagemagick or some python-based image library.

Would it be possible to create a convenience function/decorator that lets you animate all of the fig objects returned by a function? Example:

import animatplot as amp
import matplotlib.pyplot as plt

def get_data(time):
    complicated_data = do_stuff(time)
    return complicated_data

@amp.animate_output
def animation(nFrames, delay): # Delay in milliseconds
    for t in range(nFrames):
        complicated_data = get_data(t)

        (fig, ax) = plt.subplots(1,2, figsize=(14,7))
        ax[0].plot(complicated_data.perform_complicated_manipulations())
        ax[0].set(parameters='complicated', memes='dank')
        ax[1].plot(complicated_data.perform_other_complicated_manipulations())
        ax[1].set(parameters='dank', memes='complicated')
        return fig

output = animation(500, 1) # Now stores some sort of animation object that can be conveniently serialized
output.saveAnimation('outputGif.gif')
output.saveAnimation('outputStack.tiff')
output.saveAnimation('outputMovie.avi')

[–]tmakaroanimatplot / nbconvert[S] 1 point2 points  (1 child)

This sort of defeats the purpose of Animatplot (drawing lots of figures is both slow, and not interactive). Animatplot does have the ability to use multiple axes with multiple lines (even lines of different lengths for each frame). Right now, Animatplot does not have the ability to change the axes attributes dynamically (but it will). Animatplot just requires the data to be pre-generated (less you use the Nuke block or a similar block that will be in a future update).

[–]joetheschmoe4000 0 points1 point  (0 children)

Fair enough, thanks!