在三维空间绘制点,线,面
1.绘制点
用scatter()散点绘制三维坐标点
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
dot1 = [[0, 0, 0], [1, 1, 1], [
2, 2, 2], [2, 2, 3], [2, 2, 4]] # 得到五个点
plt.figure() # 得到画面
ax1 = plt.axes(projection='3d')
ax1.set_xlim(0, 5) # X轴,横向向右方向
ax1.set_ylim(5, 0) # Y轴,左向与X,Z轴互为垂直
ax1.set_zlim(0, 5) # 竖向为Z轴
color1 = ['r', 'g', 'b', 'k', 'm']
marker1 = ['o', 'v', '1', 's', 'H']
i = 0
for x in dot1:
ax1.scatter(x[0], x[1], x[2], c=color1[i],
marker=marker1[i], linewidths=4) # 用散点函数画点
i += 1
plt.show()
2.绘制线
函数plot3D(xs, ys, *args, zdir=‘z', **kwargs),用于绘