1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # matplotlib扩展包
import numpy as np

figure=plt.figure()
ax=Axes3D(figure)

x=np.arange(-2,2,0.1) # shape,40,从-2开始,0.1步长,不包括2
y=np.arange(-2,2,0.1)

X,Y=np.meshgrid(x,y)
Z=np.power(1-X,2)+100*np.power((Y-np.power(X,2)),2)

plt.xlabel('x')
plt.ylabel('y')

ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap='rainbow')
plt.show()

https://zhuanlan.zhihu.com/p/82295386 matplotlib 绘制多元函数

09271914