如何在 python ax.scatter 3D 绘图中连接点
How to connect points in python ax.scatter 3D plot
我在 python 中有一个 3D 图,是我使用 ax.scatter(x,y,z,c='r',s=100)
制作的
来自
import matplotlib.pyplot as plt
import pylab
from mpl_toolkits.mplot3d import Axes3D.
我想用一条线连接我的观点。我知道你可以用 marker='-o'
来做,但这对我来说只适用于 2D 而不是 3D。谁能帮忙?
谢谢。
Scatter 不允许连接点。参数 marker='-o'
仅适用于 plot
,不适用于 scatter
。对于 2D 和 3D 都是如此。但是你当然可以使用散点图和图
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
ax = plt.gca(projection="3d")
x,y,z = [1,1.5,3],[1,2.4,3],[3.4,1.4,1]
ax.scatter(x,y,z, c='r',s=100)
ax.plot(x,y,z, color='r')
plt.show()
我在 python 中有一个 3D 图,是我使用 ax.scatter(x,y,z,c='r',s=100)
制作的
来自
import matplotlib.pyplot as plt
import pylab
from mpl_toolkits.mplot3d import Axes3D.
我想用一条线连接我的观点。我知道你可以用 marker='-o'
来做,但这对我来说只适用于 2D 而不是 3D。谁能帮忙?
谢谢。
Scatter 不允许连接点。参数 marker='-o'
仅适用于 plot
,不适用于 scatter
。对于 2D 和 3D 都是如此。但是你当然可以使用散点图和图
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
ax = plt.gca(projection="3d")
x,y,z = [1,1.5,3],[1,2.4,3],[3.4,1.4,1]
ax.scatter(x,y,z, c='r',s=100)
ax.plot(x,y,z, color='r')
plt.show()