def genlorenz(init=[0,0.1,0],offset=[0,0,0],rr=0.,num=100,p=10,r=28,b=2.66,label=0,dt=0.01): cc=[] x=init[0] y=init[1] z=init[2] for t in range(num): cc.append([x,y,z]) x=x+dt*(-p*x+p*y) +np.random.uniform(-rr,rr,1) y=y+dt*(-x*z+r*x-y) +np.random.uniform(-rr,rr,1) z=z+dt*( x*y-b*z) +np.random.uniform(-rr,rr,1) return np.c_[np.array(cc).reshape(num,3),np.repeat(label,num)] def cshow3(data): from mpl_toolkits.mplot3d import Axes3D fig=plt.figure() ax = Axes3D(fig) cc=zip(*data) ax.scatter(cc[0],cc[1],cc[2],c=cc[3]) plt.draw() plt.show() num=1000 lorenz=genlorenz(num=num,dt=0.05) cshow3(lorenz)