发布时间:2019-09-24 08:29:45编辑:auto阅读(2843)
需要安装numpy和matplotlib库,我都是pip库安装,这样比较简单。
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d
x, y = np.mgrid[-2 : 2 : 20j, -2 : 2 : 20j]
z = 50 * np.sin(x + y) # 测试数据
ax = plt.subplot(111, projection = '3d') # 三维图形
ax.plot_surface(x, y, z, rstride = 2, cstride = 1, cmap = plt.cm.Blues_r)
ax.set_xlabel('x') # 设置坐标轴标签
ax.set_xlabel('y')
ax.set_xlabel('z')
plt.show()

参考自《Python可以这样学》414页
上一篇: Python学习:使用urllib模块读
下一篇: Python中数组的几种使用方法
53436
40277
34682
30423
25311
25110
23508
18261
15093
14612
1049°
989°
1048°
1058°
1098°
1247°
1219°
1194°
1286°
1221°