Exporting#
It’s easy.
save#
Setting save
will save the animation to disk and show it inline.
[1]:
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial.gif').render()
gifsicle: warning: trivial adaptive palette (only 53 colors in source)
[1]:
fmt#
fmt
does not have to be explicitly set; if save
is suffixed with a file format, it will use that, else if save
is not suffixed with any file format, it will default to gif.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial').render()
However, fmt
can be explicitly set as well. For example, to save as a video, set fmt
as mp4
, but note imageio-ffmpeg
is required, e.g. pip install imageio-ffmpeg
.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], save='exporting_tutorial', fmt='mp4').render()
show#
To disable showing inline, set show
to False
. If save
is set, will still save to disk.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], show=False).render()
pygifsicle#
Reduce file size of an output GIF by setting pygifiscle
to True
. If save
is not set, will write a temporary file in the current working directory.
For this to work, pip install pygifsicle
and conda install gifsicle
.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], pygifsicle=True).render()
workers#
By default, ahlive uses a single thread to output each frame, but supports multiple processes through workers
.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], workers=1).render()
progress#
The progress bar can be deactivated if desired.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], progress=False).render()
scheduler#
Sometimes, scheduler='threads'
is more efficient than scheduler='processes'
if your dataset is large.
import ahlive as ah
ah.Array([0, 1, 2], [4, 5, 6], scheduler='threads').render()