anim_save ¶
anim_save(
filename: str | PathLike[str],
animation: Animation | None = None,
*,
path: str | None = None,
) -> str
Save an animation to a file; the extension picks the format (gganimate anim_save).
Parameters:
-
filename(str) –.gif,.png/.apng(animated PNG) or.html/.htm. -
animation(Animation, default:None) –The animation; the last one :func:
animatemade when None. -
path(str, default:None) –Directory to join in front of
filename.
Returns:
-
str–Absolute path of the written file.
Raises:
-
ExportError–If there is no animation yet or the extension is not an animation format.
Examples:
>>> from ggrust import *
>>> import tempfile
>>> data = {"year": [2021, 2022], "sold": [10, 12], "fruit": ["apple"] * 2}
>>> plot = ggplot(data, aes("fruit", "sold")) + geom_col() + transition_manual("year")
>>> written = anim_save("sales.gif", animate(plot), path=tempfile.mkdtemp())