Skip to main content

Create gif from your plotly figures!

Project description

Plotly-gif



PyPI downloads license

A simple python package to generate .gif from your plotly figures. It works for both 2D and 3D figures. It can even create_gif motion for you in 3D plots.

Installation

pip install plotly-gif

Dependencies

If you are already using plotly, then you should be good. But, just in case, these are the dependencies:

  • plotly (5.9.0)
    • Plots molecules
  • kaleido (0.1.0post1)
    • Converts plotly graphs to images (png, svg, etc.)
    • I am not using the most recent version of kaleido as it does not play nice with my computer. Try the newest version, but if you are having issues install this specific version.
  • Pillow (9.2.0)
    • Used to convert png to gif.
  • numpy (1.23.1)
    • Used for math

Usage

There are three common methods:

Built-in Functions/ Macros

Currently, we have the follow:

  • two_d_time_series
  • three_d_scatter_rotate
  • more to come... or submit your own
import plotly.graph_objs as go
from plotly_gif import GIF, two_d_time_series

fig = go.Figure()
# add your traces()
# add your formatting()

gif = GIF()
two_d_time_series(gif, fig)

Decorator

If you have a function that is changing the `go.Figure' with each loop, you can add the decorator to the func.

import plotly.graph_objs as go
from plotly_gif import GIF, capture

gif = GIF()

@capture(gif)
def plot_(x_, y_):
    fig = go.Figure()
    # add your traces()
    # add your formatting()
    
    return fig

gif.create_gif() # generate gif

In-Line

This very similar to the decorator option, but you can call the image capture function directly.

import plotly.graph_objs as go
from plotly_gif import GIF, capture

gif = GIF()

def plot_(x_, y_):
    fig = go.Figure()
    # add your traces()
    # add your formatting()
    
    gif.create_image(fig)  # create_gif image for gif
    
    return fig

gif.create_gif() # generate gif

Examples

See examples folder

2d gif

3d gif

Time to generate gif (60 images per gif)

  • Simple 2D plots with small data sets (100 pts): ~10 sec
  • Simple 3D plots with small data sets (100 pts): ~1.5 min

Warning

  • If your code 'hangs' or 'gets stuck and doesn't complete' try changing kaleido versions pip install kaleido==0.1.0post1

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

plotly_gif-0.0.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

plotly_gif-0.0.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file plotly_gif-0.0.4.tar.gz.

File metadata

  • Download URL: plotly_gif-0.0.4.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.16

File hashes

Hashes for plotly_gif-0.0.4.tar.gz
Algorithm Hash digest
SHA256 62ec69f26a6a3d5e70ce5fb222fd5ef6d2d762ee85a5a6f29baa90414d059bc1
MD5 a925ecdda3a831b080280725b182c130
BLAKE2b-256 a67e44e75ca84ce06d780eea98c1ee536331f09aa5bb7d853dba02e0b876bdd4

See more details on using hashes here.

File details

Details for the file plotly_gif-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: plotly_gif-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.16

File hashes

Hashes for plotly_gif-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e57b55a1f722a2237938d8d4dbad8c0648801a79b38da39ab20201819dc670c9
MD5 0b612cfb7c4a55488e7ed90da3108e72
BLAKE2b-256 61b74dc47b459613214b30c7654e25b1665c57c5c1b5e89c29be014806145827

See more details on using hashes here.

Supported by

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