Hi all

I am trying to plot the trajectory of the Lorenz system with the axes3d.py
module (version 0.87.7). The code is the following:

from numpy import *
from scipy.integrate import odeint
import pylab as p
import matplotlib.axes3d as p3

def Lorenz(w, t, s, r, b):
    x, y, z = w
    return array([s*(y-x), r*x-y-x*z, x*y-b*z])

# Parameters
s = 8.0
r = 28.1
b = 8/3.0

w_0 = array([0., 0.8, 0.])         # Initial condition
time = arange(0., 100., 0.01) # time vector

trajectory = odeint(Lorenz, w_0, time, args=(s, r, b)) # 10^5 x 3 array

# There must be better ways to do this:
x = trajectory[:,0]
y = trajectory[:,1]
z = trajectory[:,2]

# 3D plotting
fig=p.figure()
ax = p3.Axes3D(fig)
ax.plot3D(x,y,z)   # I guess this is the method to use
p.show()

I get however some errors related with the autoscale_view() method (see below).
I have two questions: Is plot3D the correct choice for plotting a 3D
curve? In that case, is there any way to fix these errors?

Thanks a lot for your help and for making matplotlib possible,

dani

Errors (pdb output):

lorenz.py
---> 42 plot3D(x,y,z)

/usr/lib/python2.4/site-packages/matplotlib/axes3d.py in plot3D(self,
xs, ys, zs, *args, **kwargs)
    488     def plot3D(self, xs, ys, zs, *args, **kwargs):
    489         had_data = self.has_data()
--> 490         lines = Axes.plot(self, xs,ys, *args, **kwargs)
    491         if len(lines)==1:
    492             line = lines[0]

/usr/lib/python2.4/site-packages/matplotlib/axes.py in plot(self,
*args, **kwargs)
   2129         lines = [line for line in lines] # consume the generator
   2130
-> 2131         self.autoscale_view(scalex=scalex, scaley=scaley)
   2132         return lines

TypeError: autoscale_view() got an unexpected keyword argument 'scalex'
> /usr/lib/python2.4/site-packages/matplotlib/axes.py(2131)plot()
   2130
-> 2131         self.autoscale_view(scalex=scalex, scaley=scaley)
   2132         return lines

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to