# Example of the Lorenz attractor
mlab.clf()
import numpy as np
def lorenz(x, y, z, s=10., r=28., b=8./3):
"""The Lorentz system."""
u = s*(y -x)
v = r*x - y - x*z
w = x*y - b*z
return u, v, w
x, y, z = np.mgrid[-50:50:100j, -50:50:100j, -10:60:70j]
u, v, w = lorenz(x, y, z)
fig = mlab.figure(size=(400, 400), bgcolor=(0, 0, 0))
# Plot tje flow of trajectories with suitable parameters.
f = mlab.flow(x, y, z, u, v, w, line_width=3, colormap='Paired')
f.module_manager.scalar_lut_manager.reverse_lut = True
f.stream_tracer.integration_direction = 'both'
f.stream_tracer.maximum_propagation = 200
# Hide the seed:
f.seed.widget.enabled = False
# A nice view of the plot
mlab.view(140, 120, 140, [.65, 1.5, 27])
mlab.savefig('lorenz.png')