Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0ba36a

Browse files
committed
added double pendulum embedded youtube video to whats_new and documented how to do it in the coding_guide
1 parent aef53ad commit d0ba36a

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,37 @@ insert the following special comment anywhere in the script::
251251

252252
# -*- noplot -*-
253253

254+
Animations
255+
----------
256+
257+
We have a matplotlib google/gmail account with username ``mplgithub``
258+
which we used to setup the github account but can be used for other
259+
purposes, like hosting google docs or youtube videos. You can embed a
260+
matplotlib animation in the docs by first saving the animation as a
261+
movie using :meth:`matplotlib.animation.Animation.save`, and then
262+
uploading to `matplotlib's youtube
263+
channel <http://www.youtube.com/user/matplotlib>`_ and inserting the
264+
embedding string youtube provides like::
265+
266+
.. raw:: html
267+
268+
<iframe width="420" height="315"
269+
src="http://www.youtube.com/embed/32cjc6V0OZY"
270+
frameborder="0" allowfullscreen>
271+
</iframe>
272+
273+
An example save command to generate a movie looks like this
274+
275+
.. sourcecode:: python
276+
277+
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)),
278+
interval=25, blit=True, init_func=init)
279+
280+
ani.save('double_pendulum.mp4', fps=15)
281+
282+
Contact John Hunter for the login password to upload youtube videos of
283+
google docs to the mplgithub account.
284+
254285
.. _referring-to-mpl-docs:
255286

256287
Referring to mpl documents

doc/users/whats_new.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ animated figures. The :mod:`~matplotlib.animation` module is intended
3535
to replace the backend-specific examples formerly in the
3636
:ref:`examples-index` listings. Examples using the new framework are
3737
in :ref:`animation-examples-index`; see the entrancing :ref:`double
38-
pendulum <animation-double_pendulum_animated>` in action.
38+
pendulum <animation-double_pendulum_animated>` which uses
39+
:meth:`matplotlib.animation.Animation.save` to create the movie below.
40+
41+
.. raw:: html
42+
43+
<iframe width="420" height="315" src="http://www.youtube.com/embed/32cjc6V0OZY" frameborder="0" allowfullscreen></iframe>
3944

4045
This should be considered as a beta release of the framework;
4146
please try it and provide feedback.

examples/animation/double_pendulum_animated.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ def animate(i):
8484
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)),
8585
interval=25, blit=True, init_func=init)
8686

87+
#ani.save('double_pendulum.mp4', fps=15, clear_temp=False)
8788
plt.show()

lib/matplotlib/animation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def save(self, filename, fps=5, codec='mpeg4', clear_temp=True,
8787
'''
8888
Saves a movie file by drawing every frame.
8989
90+
*filename* is the output filename, eg :file:`mymovie.mp4`
91+
9092
*fps* is the frames per second in the movie
9193
9294
*codec* is the codec to be used,if it is supported by the output method.
@@ -430,7 +432,7 @@ def __init__(self, fig, func, frames=None ,init_func=None, fargs=None,
430432
self._init_func = init_func
431433

432434
# Needs to be initialized so the draw functions work without checking
433-
self._save_seq = []
435+
self._save_seq = []
434436

435437
TimedAnimation.__init__(self, fig, **kwargs)
436438

0 commit comments

Comments
 (0)