Skip to main content

mplcamera


This package is adapted from https://github.com/jwkvam/celluloid.


Instead of capturing a figures artists like celluloid does, mplcamera takes an image snapshot of the whole figure. This has the advantage that

  • all plot contents should be captured
  • we have the opportunity to use savefig keyword arguments like facecolor and bbox_inches.

Further, using imageio to save a gif provides the opportunity for using mimsave_kwargs:

  • to define a duration between frames in seconds, either as int, or as a list individually for each frame.
  • we can set the loop to 1 (gif animation stops after 1 loop) or any other amount of loops.

Disadvantages:

  • Saving the images takes a little more time than with mplcamera.
  • It might be memory intensive to store a lot of images in memory.

The goal of this package is to provide a simple way to create gifs that can be used for example

  • to show the creation process of a plot
  • to aid visual storytelling by being able to focus longer on individual frames, which allows to show annotations only for that time (simply remove them after you snap the frame.)

Installation

pip install mplcamera

Usage

The usage remains the same as with celluloid:

  1. instantiate a Camera from a figure
import matplotlib.pyplot as plt
from mplcamera import Camera
fig = plt.figure()
cam = Camera(fig)
  1. After each step of plotting take snapshots of the figure
cam.snap()
  1. save the snapshots to a gif
cam.save('animation.gif')

Example:


    import matplotlib.pyplot as plt
    from mplcamera import Camera

    fig, ax = plt.subplots()
    ax.set_ylim(-0.25, 3.25)

    cam = Camera(fig)
    for i in range(4):
        plt.plot([i] * 10)
        cam.snap()

    # use a different duration for frame 3. use loop=1 to not loop the gif
    mimsave_kwargs = {'duration': [0.25, 0.25, 1, 0.25], 'loop': 0}

    cam.save('mpl_camera_animation.gif', **mimsave_kwargs)

gif

Metadata

Release files for mplcamera 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mplcamera 0.0.2
File Interpreter ABI Platform Actions
mplcamera-0.0.2-py3-none-any.whl Python 3 none any Details for mplcamera-0.0.2-py3-none-any.whl

Release files / mplcamera-0.0.2-py3-none-any.whl

Download URL mplcamera-0.0.2-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a328f6540162281d5d1ccce182271e3c714cf2581472c1d8b6bffed82b39d9a
BLAKE2b-256 checksum
How to use checksums
68f6db71c25cc185952e6141f36702a6890e42e3c339688ddc2de269d8c2ed05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.6.1 requests/2.25.1 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.3

Security for mplcamera 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page