# Plotly-gif
---
---
![PyPI](https://img.shields.io/pypi/v/plotly_gif)
![downloads](https://img.shields.io/pypi/dm/plotly_gif)
![license](https://img.shields.io/github/license/dylanwal/plotly_gif)
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](https://github.com/plotly/plotly.py) (5.9.0)
* Plots molecules
* [kaleido](https://github.com/plotly/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](https://github.com/python-pillow/Pillow) (9.2.0)
* Used to convert png to gif.
* [numpy](https://github.com/numpy/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
```python
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.
```python
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.
```python
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](https://github.com/dylanwal/plotly_gif/blob/master/examples/gifs/example_1.gif)
![3d gif](https://github.com/dylanwal/plotly_gif/blob/master/examples/gifs/example_3.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`
Raw data
{
"_id": null,
"home_page": "https://github.com/dylanwal/plotly_gif",
"name": "plotly-gif",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Dylan Walsh",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/a6/7e/44e75ca84ce06d780eea98c1ee536331f09aa5bb7d853dba02e0b876bdd4/plotly_gif-0.0.4.tar.gz",
"platform": "any",
"description": "# Plotly-gif \r\n\r\n---\r\n---\r\n![PyPI](https://img.shields.io/pypi/v/plotly_gif)\r\n![downloads](https://img.shields.io/pypi/dm/plotly_gif)\r\n![license](https://img.shields.io/github/license/dylanwal/plotly_gif)\r\n\r\nA simple python package to generate .gif from your plotly figures. It works for both 2D and 3D figures. It can even \r\ncreate_gif motion for you in 3D plots. \r\n\r\n## Installation\r\n\r\n```\r\npip install plotly-gif\r\n```\r\n\r\n### Dependencies\r\n\r\nIf you are already using plotly, then you should be good. But, just in case, these are the dependencies:\r\n* [plotly](https://github.com/plotly/plotly.py) (5.9.0)\r\n * Plots molecules\r\n* [kaleido](https://github.com/plotly/Kaleido) (0.1.0post1)\r\n * Converts plotly graphs to images (png, svg, etc.)\r\n * I am not using the most recent version of kaleido as it does not play nice with my computer. Try the newest \r\n version, but if you are having issues install this specific version.\r\n* [Pillow](https://github.com/python-pillow/Pillow) (9.2.0)\r\n * Used to convert png to gif.\r\n* [numpy](https://github.com/numpy/numpy) (1.23.1)\r\n * Used for math\r\n \r\n \r\n---\r\n## Usage\r\n\r\nThere are three common methods:\r\n\r\n### Built-in Functions/ Macros\r\nCurrently, we have the follow:\r\n* two_d_time_series\r\n* three_d_scatter_rotate\r\n* more to come... or submit your own\r\n\r\n```python\r\nimport plotly.graph_objs as go\r\nfrom plotly_gif import GIF, two_d_time_series\r\n\r\nfig = go.Figure()\r\n# add your traces()\r\n# add your formatting()\r\n\r\ngif = GIF()\r\ntwo_d_time_series(gif, fig)\r\n\r\n```\r\n\r\n\r\n\r\n\r\n### Decorator\r\n\r\nIf you have a function that is changing the `go.Figure' with each loop, you can add the decorator to the func.\r\n\r\n```python\r\nimport plotly.graph_objs as go\r\nfrom plotly_gif import GIF, capture\r\n\r\ngif = GIF()\r\n\r\n@capture(gif)\r\ndef plot_(x_, y_):\r\n fig = go.Figure()\r\n # add your traces()\r\n # add your formatting()\r\n \r\n return fig\r\n\r\ngif.create_gif() # generate gif\r\n```\r\n\r\n### In-Line\r\nThis very similar to the decorator option, but you can call the image capture function directly.\r\n\r\n```python\r\nimport plotly.graph_objs as go\r\nfrom plotly_gif import GIF, capture\r\n\r\ngif = GIF()\r\n\r\ndef plot_(x_, y_):\r\n fig = go.Figure()\r\n # add your traces()\r\n # add your formatting()\r\n \r\n gif.create_image(fig) # create_gif image for gif\r\n \r\n return fig\r\n\r\ngif.create_gif() # generate gif\r\n```\r\n\r\n---\r\n## Examples\r\nSee examples folder\r\n\r\n![2d gif](https://github.com/dylanwal/plotly_gif/blob/master/examples/gifs/example_1.gif)\r\n\r\n\r\n![3d gif](https://github.com/dylanwal/plotly_gif/blob/master/examples/gifs/example_3.gif)\r\n\r\n\r\n\r\n### Time to generate gif (60 images per gif)\r\n* Simple 2D plots with small data sets (100 pts): ~10 sec\r\n* Simple 3D plots with small data sets (100 pts): ~1.5 min\r\n\r\n\r\n## Warning\r\n\r\n* If your code 'hangs' or 'gets stuck and doesn't complete' try changing kaleido versions `pip install kaleido==0.1.0post1`\r\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Create gif from your plotly figures!",
"version": "0.0.4",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61b74dc47b459613214b30c7654e25b1665c57c5c1b5e89c29be014806145827",
"md5": "0b612cfb7c4a55488e7ed90da3108e72",
"sha256": "e57b55a1f722a2237938d8d4dbad8c0648801a79b38da39ab20201819dc670c9"
},
"downloads": -1,
"filename": "plotly_gif-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0b612cfb7c4a55488e7ed90da3108e72",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8222,
"upload_time": "2023-04-10T12:37:41",
"upload_time_iso_8601": "2023-04-10T12:37:41.793328Z",
"url": "https://files.pythonhosted.org/packages/61/b7/4dc47b459613214b30c7654e25b1665c57c5c1b5e89c29be014806145827/plotly_gif-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a67e44e75ca84ce06d780eea98c1ee536331f09aa5bb7d853dba02e0b876bdd4",
"md5": "a925ecdda3a831b080280725b182c130",
"sha256": "62ec69f26a6a3d5e70ce5fb222fd5ef6d2d762ee85a5a6f29baa90414d059bc1"
},
"downloads": -1,
"filename": "plotly_gif-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "a925ecdda3a831b080280725b182c130",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6740,
"upload_time": "2023-04-10T12:37:43",
"upload_time_iso_8601": "2023-04-10T12:37:43.743234Z",
"url": "https://files.pythonhosted.org/packages/a6/7e/44e75ca84ce06d780eea98c1ee536331f09aa5bb7d853dba02e0b876bdd4/plotly_gif-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-10 12:37:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "dylanwal",
"github_project": "plotly_gif",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "plotly-gif"
}