Animation in a notebook using holoviews
An easy way to include movie in a notebook using Holoviews.
In [1]:
import numpy as np
from holoviews import HoloMap, VectorField
%load_ext holoviews.ipython
In [2]:
steps = np.linspace(-2.5, 2.5, 41)
x,y = np.meshgrid(steps, steps)
sine_rings = np.sin(x**2+y**2)*np.pi+np.pi
exp_falloff = 1/np.exp((x**2+y**2)/15)
vector_data = np.array([x.flatten()/5., y.flatten()/5., sine_rings.flatten(), exp_falloff.flatten()]).T
vectors = VectorField(vector_data, group='Sine Ring')
In [3]:
%output size=200
%opts VectorField [color_dim='angle' title_format='{group} {type}'] (cmap='hsv')
In [4]:
vectors
Out[4]:
In [5]:
holomap = HoloMap()
for deg in np.linspace(0, 360, 40, endpoint=False):
vector_data = np.array([x.flatten()/5., y.flatten()/5.,
np.sin(deg*2*np.pi/360)*sine_rings.flatten(),
exp_falloff.flatten()]).T
holomap[deg] = VectorField(vector_data, group='Sine Ring')
holomap
Out[5]: