同一 3D 轴中的多条独立线

2023-12-09

I would like to draw multiple independent lines in a 3D plot in Python. It looks like: enter image description here.

我是 Python 新手。你能帮我吗?


您必须使用 matplotlib 库(mplot3d包裹)。

这是一个带有线条的 3dr 图的小示例:

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt

# make 3d axes
fig = plt.figure()
ax = fig.gca(projection='3d')

# test data
x = np.arange(-1., 1., .1)
y = np.arange(-1., 1., .1)
z1 = x + y
z2 = x * x
z3 = -y * y

# plot test data
ax.plot(x, y, z1)
ax.plot(x, y, z2)
ax.plot(x, y, z3)

# make labels
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

plt.show()

enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

同一 3D 轴中的多条独立线 的相关文章

随机推荐