Lorenz attractor example

URL: http://bokeh.pydata.org/en/latest/docs/gallery/lorenz.html

Most examples work across multiple plotting backends, this example is also available for:

In [1]:
import numpy as np
import holoviews as hv
hv.extension('matplotlib')

Declare the data

In [2]:
from scipy.integrate import odeint

sigma = 10
rho = 28
beta = 8.0/3
theta = 3 * np.pi / 4

def lorenz(xyz, t):
    x, y, z = xyz
    x_dot = sigma * (y - x)
    y_dot = x * rho - x * z - y
    z_dot = x * y - beta* z
    return [x_dot, y_dot, z_dot]

initial = (-10, -7, 35)
t = np.arange(0, 100, 0.006)

solution = odeint(lorenz, initial, t)

x = solution[:, 0]
y = solution[:, 1]
z = solution[:, 2]
xprime = np.cos(theta) * x - np.sin(theta) * y

lorenzian = hv.Overlay([hv.Path(d) for d in zip(np.array_split(xprime, 7), np.array_split(z, 7))])

Plot

In [3]:
lorenzian(style={'Path': dict(color=hv.Palette('Blues'), linewidth=1)})
Out[3]:

Download this notebook from GitHub (right-click to download).