#打算用python画matlab里peaks函数的图像,代码如下,但是Z的计算那部分不太正确,请问应该如何修改?
from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
figure = plt.figure()
ax = Axes3D(figure)
X = np.arange(-20,20,0.25)
Y = np.arange(-20,20,0.25)
X,Y = np.meshgrid(X,Y)
Z = 3*(1-X)**2*np.exp(-(X**2) - (Y+1)**2)- 10*(X/5 - X**3 - Y**5)*np.exp(-X*
*2-X**2)- 1/3*np.exp(-(X+1)**2 - Y**2)
ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap='rainbow')
plt.show()
--
FROM 115.57.131.*