From b14a6883cd89ff3652d5c5e3d69b3dd2625a64dd Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 15 Sep 2021 16:04:11 +0100 Subject: [PATCH 1/3] 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..8133fe3387e7 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 to disk 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..f326c28640c8 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 From 196edf80c5e8f16e4b5ba1422422a5a37da7b9d0 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 22 Sep 2021 19:00:21 -0400 Subject: [PATCH 2/3] Update lib/matplotlib/animation.py Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- lib/matplotlib/animation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index f326c28640c8..88e79bb4ab4f 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -1311,7 +1311,7 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None): 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'``. + is True, otherwise ``'once'``. """ if fps is None and hasattr(self, '_interval'): # Convert interval in ms to frames per second From 2ffffb47358e604f23c9ce8b2bcadf2cdf355340 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sat, 25 Sep 2021 11:47:35 +0100 Subject: [PATCH 3/3] Clarify animation saving Co-authored-by: Thomas A Caswell --- doc/api/animation_api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/animation_api.rst b/doc/api/animation_api.rst index 8133fe3387e7..7ad0f5c150c6 100644 --- a/doc/api/animation_api.rst +++ b/doc/api/animation_api.rst @@ -32,7 +32,7 @@ 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`, `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