diff --git a/nafuma/plotting.py b/nafuma/plotting.py index 99b7d7f..3a0b71b 100644 --- a/nafuma/plotting.py +++ b/nafuma/plotting.py @@ -14,6 +14,8 @@ import matplotlib.lines as mlines import matplotlib.markers as mmarkers import itertools +from PIL import Image +import os import numpy as np @@ -465,3 +467,22 @@ def connect_inset(parent_axes, inset_axes, loc1a=1, loc1b=1, loc2a=2, loc2b=2, * +def make_animation(paths, options={}): + + default_options = { + 'save_folder': '.', + 'save_filename': 'animation.gif', + 'fps': 5 + } + + options = aux.update_options(options=options, default_options=default_options) + + + frames = [] + for path in paths: + frame = Image.open(path) + frames.append(frame) + + frames[0].save(os.path.join(options['save_folder'], options['save_filename']), format='GIF', append_images=frames[1:], save_all=True, duration=(1/options['fps'])*1000, loop=0) + + \ No newline at end of file