1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import os import numpy as np import matplotlib.pyplot as plt from scipy import integrate from mpl_toolkits.mplot3d.axes3d import Axes3D os.chdir(r'D:\projects\wordpress\ex36') os.getcwd() def f(xyz, t, rho, sigma, beta): x, y, z = xyz return [sigma*(y-x),x*(rho-z)-y,x*y-beta*z] rho = 28 sigma = 8 beta = 8/3.0 t = np.linspace(0, 25, 10000) xyz0 = [1.0, 1.0, 1.0] xyz1 = integrate.odeint(f, xyz0, t, args=(rho, sigma, beta)) xyz2 = integrate.odeint(f, xyz0, t, args=(rho, sigma, 0.6*beta)) xyz3 = integrate.odeint(f, xyz0, t, args=(rho, 2*sigma, 0.6*beta)) print(xyz3.shape) fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 6), subplot_kw={'projection': '3d'}) for ax, xyz, c in [(ax1, xyz1, 'r'), (ax2, xyz2, 'b'), (ax3, xyz3, 'g')]: ax.plot(xyz[:,0], xyz[:,1], xyz[:,2], c, alpha=0.5) ax.set_xlabel('$x$', fontsize=14) ax.set_ylabel('$y$', fontsize=14) ax.set_zlabel('$z$', fontsize=14) ax.set_xticks([-15, 0, 15]) ax.set_yticks([-20, 0, 20]) ax.set_zticks([0, 20, 40]) plt.savefig("example36.png", dpi=100) plt.show() plt.close() <img class=" wp-image-170 aligncenter" src="https://gantovnik.com/bio-tips/wp-content/uploads/2019/01/example36.png" alt="example36" width="575" height="246" /> |
Recent Comments