#!/usr/bin/env python # coding: utf-8 # ## jsHTML version # In[1]: import matplotlib.pyplot as plt import matplotlib.animation import numpy as np t = np.linspace(0, 6*np.pi, num=60) x = 2.0 * np.cos(t) + 5.0 * np.cos(2.0/3.0 * t) y = 2.0 * np.sin(t) - 5.0 * np.sin(2.0/3.0 * t) fig, ax = plt.subplots(figsize=(5, 5)) l, = ax.plot([-7, 7],[-7, 7]) animate = lambda i: l.set_data(x[:i], y[:i]) ani = matplotlib.animation.FuncAnimation(fig, animate, frames=len(t), interval = 1000/30.0) from IPython.display import HTML HTML(ani.to_jshtml()) # ## nbagg version # In[2]: get_ipython().run_line_magic('matplotlib', 'nbagg') import matplotlib.pyplot as plt import matplotlib.animation import numpy as np t = np.linspace(0, 6*np.pi, num=60) x = 2.0 * np.cos(t) + 5.0 * np.cos(2.0/3.0 * t) y = 2.0 * np.sin(t) - 5.0 * np.sin(2.0/3.0 * t) fig, ax = plt.subplots(figsize=(5, 5)) l, = ax.plot([-7, 7],[-7, 7]) animate = lambda i: l.set_data(x[:i], y[:i]) ani = matplotlib.animation.FuncAnimation(fig, animate, frames=len(t), interval = 1000/30.0) # In[ ]: