三维散点图:
X1 = np.array([ [0, 0, 0], [2, 0, 0], [2, 0, 1], [1, 2, 0] ]) X2 = np.array([ [0, 0, 1], [0, 1, 0], [0, -2, 1], [1, 1, -2] ]) fig = plt.figure() ax = fig.gca(projection="3d") ax.scatter(X1[:, 0], X1[:, 1], zs=X1[:, 2], zdir="z", c="#00DDAA", marker="o", s=40) ax.scatter(X2[:, 0], X2[:, 1], zs=X2[:, 2], zdir="z", c="#FF5511", marker="^", s=40) ax.set(xlabel="X", ylabel="Y", zlabel="Z") plt.show()
结果如下:
标签:matplotlib,案例,绘图,X2,ax,array,X1,marker,zs From: https://www.cnblogs.com/zhaoke271828/p/17004899.html