From 55cb6ad392c91b27719642b3cdbcfe7c210fc904 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 26 Sep 2021 22:33:06 +0200 Subject: [PATCH] Backport PR #21081: Improve docs for to_jshtml() --- doc/api/animation_api.rst | 3 ++- lib/matplotlib/animation.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/api/animation_api.rst b/doc/api/animation_api.rst index 4ccded4d8ca4..7ad0f5c150c6 100644 --- a/doc/api/animation_api.rst +++ b/doc/api/animation_api.rst @@ -32,7 +32,8 @@ to. If you do not hold a reference to the `Animation` object, it (and hence the timers) will be garbage collected which will stop the animation. -To save an animation to disk use `Animation.save` or `Animation.to_html5_video` +To save an animation use `Animation.save`, `Animation.to_html5_video`, +or `Animation.to_jshtml`. See :ref:`ani_writer_classes` below for details about what movie formats are supported. diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index f93f6f1559d0..88e79bb4ab4f 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -1299,7 +1299,20 @@ def to_html5_video(self, embed_limit=None): return 'Video too large to embed.' def to_jshtml(self, fps=None, embed_frames=True, default_mode=None): - """Generate HTML representation of the animation""" + """ + Generate HTML representation of the animation. + + Parameters + ---------- + fps : int, optional + Movie frame rate (per second). If not set, the frame rate from + the animation's frame interval. + embed_frames : bool, optional + default_mode : str, optional + What to do when the animation ends. Must be one of ``{'loop', + 'once', 'reflect'}``. Defaults to ``'loop'`` if ``self.repeat`` + is True, otherwise ``'once'``. + """ if fps is None and hasattr(self, '_interval'): # Convert interval in ms to frames per second fps = 1000 / self._interval