1 # 实例:
2 # 首先,还是需要取坐标
3 import numpy as np
# 假设,m是给定的三维散点序列
4 m = np.array([[1, 3, 3],
5 [4, 1, 6],
6 [1, 4, 3],
7 [1, 6, 3]])
8 x = [x[0] for x in m]
9 y = [x[1] for x in m]
10 z = [x[2] for x in m]
11 print(x)
12 print(y)
13 print(z)
14
15 # 然后正常画图
16 import matplotlib.pyplot as plt
17 import mpl_toolkits.mplot3d
18
19 ax = plt.subplot(projection = '3d') # 创建一个三维的绘图工程
20 ax.set_title('3d_image_show') # 设置本图名称
21 ax.scatter(x, y, z, c = 'r') # 绘制数据点 c: 'r'红色,'y'黄色,等颜色
22
23 ax.set_xlabel('X') # 设置x坐标轴
24 ax.set_ylabel('Y') # 设置y坐标轴
25 ax.set_zlabel('Z') # 设置z坐标轴
26
27 plt.show()
![](https://img2020.cnblogs.com/blog/1108901/202004/1108901-20200414021108251-663958691.png)