Skip to main content

Make animated gifs out of multiple data plots.

Project description

https://badge.fury.io/py/datagif.svg

A Python package for easily making clean animated gifs of data plots, datagif is built on top of seaborn to manage the plot generation, and imageio to manage creating the animated gif.

Example GIF

Code for this example can be found in the examples directory.

https://raw.githubusercontent.com/Matyasz/datagif/master/readme_assets/gaussian_scatter.gif

How to use datagif

The method you need is named after the package, so use the following import statement

from datagif import datagif

Your data will need to be in the form of a pandas DataFrame, with at least three columns. Select one to be the time dimension, and then the simplest example looks like the following

datagif(
    plots='scatterplot',
    save_dir='/path/to/plot/dir',
    name='GIF',
    data=df,
    x='x',
    y='y',
    t='time'
)

Customizing your GIF

There are four important arguments for customizing your GIF and the plots that make it up:

  • plt_funcs (Functions that are normally called like plt.title())

  • seaborn_funcs (Functions that are normally called like sns.set_theme())

  • seaborn_args (Arguments to add to the plot functions)

  • imageio_args (Arguments for the imageio get_writer() method)

For the _funcs arguments, these should be in the form of a dict where the keys are strings of the names of the functions you want to call, and the values should be the arguments you want to pass to the functions. These values can themselves be

  • a single value, like a string

  • a list to be unpacked and passed to the function

  • a dictionary to be unpacked and passed to the function as keyword arguments

For the _args arguments, these should be in the form of a dict that will be passed to the plotting and imageio functions as keyword arguments.

Using multiple plots in one GIF

As in the example above, you can layer multiple plots in one GIF! To do this, simply make the plots argument a list of valid strings. Then also make the x, y, seaborn_args arguments into lists of valid values the same length as the plots list, and the nth entry of these other arguments will be used for the nth plot.

Helpful Tips

It is strongly recommended to use the tight_layout method in the plt_funcs argument. This will help prevent small differences between the plots produced, leading to a much cleaner GIF.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datagif-0.1.1.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

datagif-0.1.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file datagif-0.1.1.tar.gz.

File metadata

  • Download URL: datagif-0.1.1.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.3

File hashes

Hashes for datagif-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1ec4dbe7bea833db43816e9ef8d7d8babf485783d764d798f85dd7c680987152
MD5 2e23b31cc53590dbb39adf1ae6c7b1ef
BLAKE2b-256 b84dd72766465a2240131c002a7ada238f8ddf53ee56f9423d52eaf8273a9981

See more details on using hashes here.

File details

Details for the file datagif-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: datagif-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.3

File hashes

Hashes for datagif-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bc2320cf5557aea156ede306cf75ec52ed8117bf7f079a4d7d9355de762e63a
MD5 9aaab04106fe8a416fe88a8b468c3901
BLAKE2b-256 c2123cf8e31464d0e2003d5db9091687614757bb46dae6e0b6b8c581a2577cca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page