matplotlib画二元函数图像 2023-10-29 123456789101112131415161718from matplotlib import pyplot as pltfrom mpl_toolkits.mplot3d import Axes3D # matplotlib扩展包import numpy as npfigure=plt.figure()ax=Axes3D(figure)x=np.arange(-2,2,0.1) # shape,40,从-2开始,0.1步长,不包括2y=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