Skip to content

Backport PR #21081 on branch v3.5.x (Improve docs for to_jshtml()) #21183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/animation_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 14 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down