Python
# 导入画图模块
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
import numpy as np
# 定义两个函数
def z1(x,y):
return 0.02 * x + 0.015 * y - 0.00008 * x * y + 0.00007 * x * x - 0.00002 * y * y + 15
def z2(x,y):
return 0.02 * x + 0.015 * y - 0.00008 * x * y + 0.00007 * x * x - 0.00002 * y * y + 20
x = np.linspace(0,100,40,endpoint = False)
y = np.linspace(0,300,40,endpoint = False)
X, Y = np.meshgrid(x, y)
Z1 = z1(X,Y)
Z2 = z2(X,Y)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(X, Y, Z1, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.plot_surface(X, Y, Z2, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
# ax.plot_wireframe(X, Y, Z1,color = 'orange')
# ax.plot_wireframe(X, Y, Z2,color = 'skyblue')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
#调整观察角度和方位角。这里将俯仰角设为60度,把方位角调整为35度
ax.view_init(60, 35)
ax.set_title('surface')
# C:/Users/Admin/Desktop/result.jpg为图片存储路径,改为你自己的路径即可
pl