Thanks to visit codestin.com
Credit goes to github.com

Skip to content

maxhumber/gif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gif

GitHub Travis PyPI Downloads

About

gif is a better way to build animated Matplotlib gifs.

Installation

pip install -U gif

Usage

gif is easy to use. Just import:

import gif
from matplotlib import pyplot as plt

Decorate a Matplotlib plot function with gif.frame:

@gif.frame
def plot(x, y):
    plt.figure(figsize=(5, 3), dpi=100)
    plt.scatter(x, y)
    plt.xlim((0, 100))
    plt.ylim((0, 100))

Build a bunch of "frames" with a standard for loop:

from random import randint

frames = []
for _ in range(50):
    x = [randint(0, 100) for _ in range(10)]
    y = [randint(0, 100) for _ in range(10)]
    frame = plot(x, y)
    frames.append(frame)

Select the duration (milliseconds) between each frame and save:

gif.save(frames, "examples/chaos.gif", duration=100)

Examples

Chaos (code):

chaos.gif

Preferential Attachment (code, theory):

attachment.gif

Wave (code, original):

wave.gif

Hypothetical Outcome Plot (code, original):

hop.gif

Polar Plot (code, data, inspiration):

canada.gif

Tornado (code, inspiration):

tornado.gif

About

The matplotlib Animation Extension

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 7