Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxhumber/gif
The matplotlib Animation Extension
https://github.com/maxhumber/gif
gif gif-animation matplotlib pil pillow python
Last synced: 3 days ago
JSON representation
The matplotlib Animation Extension
- Host: GitHub
- URL: https://github.com/maxhumber/gif
- Owner: maxhumber
- License: mit
- Created: 2020-01-30T03:06:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-02T13:18:25.000Z (over 1 year ago)
- Last Synced: 2024-09-30T23:24:12.621Z (3 months ago)
- Topics: gif, gif-animation, matplotlib, pil, pillow, python
- Language: Python
- Homepage:
- Size: 57 MB
- Stars: 661
- Watchers: 11
- Forks: 49
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-meteo - gif
- awesome-vega - gif - GIFs from Altair/Matplotlib/Plotly charts. (Altair / Packages)
README
### About
The [matplotlib](https://matplotlib.org/) Animation Extension
### Install & Import
```sh
pip install gif
``````python
import gif
```### Quickstart
```python
import gif
from random import randint
from matplotlib import pyplot as pltx = [randint(0, 100) for _ in range(100)]
y = [randint(0, 100) for _ in range(100)]# (Optional) Set the dots per inch resolution to 300
gif.options.matplotlib["dpi"] = 300# Decorate a plot function with @gif.frame
@gif.frame
def plot(i):
xi = x[i*10:(i+1)*10]
yi = y[i*10:(i+1)*10]
plt.scatter(xi, yi)
plt.xlim((0, 100))
plt.ylim((0, 100))# Construct "frames"
frames = [plot(i) for i in range(10)]# Save "frames" to gif with a specified duration (milliseconds) between each frame
gif.save(frames, 'example.gif', duration=50)
```### Examples
| [![arrival.gif](images/arrival.gif)](examples/arrival.py) | [![hop.gif](images/hop.gif)](examples/hop.py) | [![phone.gif](images/phone.gif)](examples/phone.py) |
| ------------------------------------------------------------ | ------------------------------------------------------ | --------------------------------------------------- |
| [![seinfeld.gif](images/seinfeld.gif)](examples/seinfeld.py) | [![spiral.gif](images/spiral.gif)](examples/spiral.py) | [![heart.gif](images/heart.gif)](heart.py) |### Warning
Altair and Plotly are no longer supported in `22.5.0`+
Please use `pip install gif==3.0.0` if you still need to interface with these libraries