在matplotlib中绘制多条三维线

2024-06-01 02:58:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在matplotlib 3D轴上画很多线,但是失败了。一般来说,我不知道在哪里可以找到有关收藏品和艺术家的文档。。。你知道吗

这就是我目前的想法

# start and stop are structured arrays
plt.ion
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, projection='3d')

lines = []
for i in range(100):

    lines.append(Line3D(
        [
            start['x'][i], stop['x'][i]
        ],
        [
            start['y'][i], stop['y'][i]
        ],
        [
            start['z'][i], stop['z'][i]
        ],
        ))

#ax2.add_collection3d(Line3DCollection(lines))
col = Line3DCollection(lines)
ax2.add_collection3d(col)

matplotlib图形确实打开了,但我一单击它,它就会出现异常。你知道吗


Tags: and文档addmatplotlibpltcolstart收藏品