Skip to content

DOC MEP12 - converted animation to SG/MEP12 compatible #7329

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
merged 2 commits into from
Oct 31, 2016
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
9 changes: 9 additions & 0 deletions examples/animation/animate_decay.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
=====
Decay
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs another word, "Decay animation", or something.

=====

This example showcases a sinusoidal decay animation.
"""


import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
Expand Down
15 changes: 13 additions & 2 deletions examples/animation/basic_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
=========================
Simple animation examples
=========================

This example contains two animations. The first is a random walk plot. The
second is an image animation.
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
Expand All @@ -17,7 +26,8 @@ def update_line(num, data, line):
plt.title('test')
line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
interval=50, blit=True)
#line_ani.save('lines.mp4')

# To save the animation, use the command: line_ani.save('lines.mp4')

fig2 = plt.figure()

Expand All @@ -30,6 +40,7 @@ def update_line(num, data, line):

im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000,
blit=True)
#im_ani.save('im.mp4', metadata={'artist':'Guido'})
# To save this second animation with some metadata, use the following command:
# im_ani.save('im.mp4', metadata={'artist':'Guido'})

plt.show()
12 changes: 10 additions & 2 deletions examples/animation/basic_example_writer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Same as basic_example, but writes files using a single MovieWriter instance
# without putting on screen
"""
===================
Saving an animation
===================

This example showcases the same animations as `basic_example.py`, but instead
of displaying the animation to the user, it writes to files using a
MovieWriter instance.
"""

# -*- noplot -*-
import numpy as np
import matplotlib
Expand Down
11 changes: 11 additions & 0 deletions examples/animation/bayes_update.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""
================
The Bayes update
================

This animation displays the posterior estimate updates as it is refitted when
new data arrives.
The vertical line represents the theoretical value to which the plotted
distribution should converge.
"""

# update a distribution based on new data.
import numpy as np
import matplotlib.pyplot as plt
Expand Down
10 changes: 9 additions & 1 deletion examples/animation/double_pendulum_animated.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
===========================
The double pendulum problem
===========================

This animation illustrates the double pendulum problem.
"""

# Double pendulum formula translated from the C code at
# http://www.physics.usyd.edu.au/~wheat/dpend_html/solve_dpend.c

Expand Down Expand Up @@ -86,5 +94,5 @@ def animate(i):
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)),
interval=25, blit=True, init_func=init)

#ani.save('double_pendulum.mp4', fps=15)
# ani.save('double_pendulum.mp4', fps=15)
plt.show()
6 changes: 5 additions & 1 deletion examples/animation/dynamic_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""
=================
An animated image
=================

This example demonstrates how to animate an image.
"""
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -14,7 +18,7 @@ def f(x, y):
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)

im = plt.imshow(f(x, y), cmap=plt.get_cmap('viridis'), animated=True)
im = plt.imshow(f(x, y), animated=True)


def updatefig(*args):
Expand Down
12 changes: 8 additions & 4 deletions examples/animation/dynamic_image2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""
An animated image
========================================
An animated image using a list of images
========================================

This examples demonstrates how to animate an image from a list of images (or
Artists).
"""
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -20,13 +25,12 @@ def f(x, y):
for i in range(60):
x += np.pi / 15.
y += np.pi / 20.
im = plt.imshow(f(x, y), cmap='viridis', animated=True)
im = plt.imshow(f(x, y), animated=True)
ims.append([im])

ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
repeat_delay=1000)

#ani.save('dynamic_images.mp4')

# ani.save('dynamic_images.mp4')

plt.show()
7 changes: 6 additions & 1 deletion examples/animation/histogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"""
==================
Animated histogram
==================

This example shows how to use a path patch to draw a bunch of
rectangles for an animated histogram
rectangles for an animated histogram.

"""
import numpy as np

Expand Down
15 changes: 11 additions & 4 deletions examples/animation/moviewriter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# This example uses a MovieWriter directly to grab individual frames and
# write them to a file. This avoids any event loop integration, but has
# the advantage of working with even the Agg backend. This is not recommended
# for use in an interactive setting.
"""
===========
MovieWriter
===========

This example uses a MovieWriter directly to grab individual frames and write
them to a file. This avoids any event loop integration, but has the advantage
of working with even the Agg backend. This is not recommended for use in an
interactive setting.

"""
# -*- noplot -*-

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions examples/animation/rain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
===============
Rain simulation
===============

Simulates rain drops on a surface by animating the scale and opacity
of 50 scatter points.
Expand Down
9 changes: 9 additions & 0 deletions examples/animation/random_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
===========
Random data
===========

An animation of random data.

"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
Expand Down
4 changes: 4 additions & 0 deletions examples/animation/simple_3danim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
============
3D animation
============

A simple example of an animated plot... In 3D!
"""
import numpy as np
Expand Down
7 changes: 5 additions & 2 deletions examples/animation/strip_chart_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Emulate an oscilloscope. Requires the animation API introduced in
matplotlib 1.0 SVN.
============
Oscilloscope
============

Emulates an oscilloscope.
"""
import numpy as np
from matplotlib.lines import Line2D
Expand Down
21 changes: 14 additions & 7 deletions examples/animation/subplots.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
"""
=================
Animated subplots
=================

This example uses subclassing, but there is no reason that the proper function
couldn't be set up and then use FuncAnimation. The code is long, but not
really complex. The length is due solely to the fact that there are a total of
9 lines that need to be changed for the animation as well as 3 subplots that
need initial set up.

"""

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import matplotlib.animation as animation


# This example uses subclassing, but there is no reason that the proper
# function couldn't be set up and then use FuncAnimation. The code is long, but
# not really complex. The length is due solely to the fact that there are a
# total of 9 lines that need to be changed for the animation as well as 3
# subplots that need initial set up.
class SubplotAnimation(animation.TimedAnimation):
def __init__(self):
fig = plt.figure()
Expand Down Expand Up @@ -63,7 +71,6 @@ def __init__(self):
def _draw_frame(self, framedata):
i = framedata
head = i - 1
head_len = 10
head_slice = (self.t > self.t[i] - 1.0) & (self.t < self.t[i])

self.line1.set_data(self.x[:i], self.y[:i])
Expand Down Expand Up @@ -93,5 +100,5 @@ def _init_draw(self):
l.set_data([], [])

ani = SubplotAnimation()
#ani.save('test_sub.mp4')
# ani.save('test_sub.mp4')
plt.show()
4 changes: 4 additions & 0 deletions examples/animation/unchained.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
========================
MATPLOTLIB **UNCHAINED**
========================

Comparative path demonstration of frequency from a fake signal of a pulsar.
(mostly known because of the cover for Joy Division's Unknown Pleasures)

Expand Down