Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I plot a 3D Lorenz attractor with x, y and z labels?

I have been attempting to perform a 3D wireframe plot of the solution to the Lorenz equations, which is stored in the cartesian variables X, Y and Z. This is what I am presently using (unsuccessfully I might add):

 # Plot the result
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.figure(1)
plt.xlabel('X(t)')
plt.ylabel('Y(t)')
plt.zlabel('Z(t)')
axes3d.plot_wireframe(X,Y,Z)
plt.show()

How to get this plot to work?

How do I plot a 3D Lorenz attractor with x, y and z labels?

I have been attempting to perform a 3D wireframe plot of the solution to the Lorenz equations, which is stored in the cartesian variables X, Y and Z. This is what I am presently using (unsuccessfully I might add):

 # Plot the result
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.figure(1)
plt.xlabel('X(t)')
plt.ylabel('Y(t)')
plt.zlabel('Z(t)')
axes3d.plot_wireframe(X,Y,Z)
plt.show()

How to do I get this plot to work?

How do I plot a 3D Lorenz attractor with x, y and z labels?

I have been attempting to perform a 3D wireframe plot of the solution to the Lorenz equations, which is stored in the variables X, Y and Z. This is what I am presently using (unsuccessfully I might add):

 # Plot the result
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.figure(1)
plt.xlabel('X(t)')
plt.ylabel('Y(t)')
plt.zlabel('Z(t)')
axes3d.plot_wireframe(X,Y,Z)
plt.show()

How do I get this plot to work?work? I'm guessing you'll probably be able to guess that X, Y and Z are ndarrays, produced from this SageMath script:

x,y,z=var('x,y,z')

# Next we define the parameters
sigma=10
rho=28
beta=8/3

# The Lorenz equations
lorenz=[sigma*(y-x),x*(rho-z)-y,x*y-beta*z]

# Time and initial conditions
N=250000
tmax=250
h=tmax/N
t=srange(0,tmax+h,h)
ics=[0,1,1]
sol=desolve_odeint(lorenz,ics,t,[x,y,z],rtol=1e-13,atol=1e-14)
X=sol[:,0]
Y=sol[:,1]
Z=sol[:,2]