from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
import numpy as np
fig = plt.figure(figsize=(1[![enter image description here][1]][1]5,10))
ax = fig.add_subplot(111, projection='3d')
# points
xs = np.asarray([np.cos(i) for i in np.arange(0,np.pi/2,(np.pi/2)/10)])
ys = np.arange(0,10,1)
zs = np.arange(0,10,1)
# plot points
ax.scatter(xs=xs, ys=ys, zs=zs, s=200, c=zs, cmap=cm.viridis_r, alpha=1.0)
# create the line
zs_l = np.asarray([[i, -1] for i in zs])
# color list
cl = [cm.get_cmap('viridis_r')(i/zs_l.shape[0]) for i in range(zs_l.shape[0])]
# draw the lines
for i, p in enumerate(zs_l):
ax.plot(xs=[xs[i]]*2, ys=[ys[i]]*2, zs=zs_l[i], markersize=0, lw=3, c=cl[i])
这没有任何意义。如果你在三维空间中工作,那么每个点都可以在三维空间中描述,包括你的起点。在三维空间中用两个坐标来描述事物本质上就是在描述一条直线;如果只显式地标记x和y坐标,那么所有可能的z值都是有效的,所以最终得到的是一条直线。
你要做的是使其中一个坐标(x,y,z)为零。
这是我所做的。
相关问题 更多 >
编程相关推荐