2
我有一个Plotly Scatter3d()
阴谋,我想在其中一些之间画线。从身体上讲,我有一个网络,我有一些节点与债券相连,我想绘制这些债券。我该如何解决它?将特定线条添加到Plotly Scatter3d()阴谋
Scatter3d()
附带一个mode='lines+markers'
选项,该选项只是使其成为点和线散点图,而不是默认的仅限于点的图。这不是我正在寻找的。我想提供一对xyz坐标的列表,并且最后我想要一组线。
这里是我的绘制简单的Scatter3d()
绘图功能:
def Splot3dPlotly(xyz):
'''
3D scatter plot using Plotly.
:param xyz: (NPx3) array of xyz positions
:return: A Plotly figure that can now be plotted as usual.
'''
xyz = np.reshape(xyz, (int(xyz.size/3), 3))
NN = int(sqrt(xyz.shape[0]))
trace1 = go.Scatter3d(
x=xyz[:,0],
y=xyz[:,1],
z=xyz[:,2],
mode = 'markers', # 'lines+markers',
marker=dict(color=range(NN*NN), colorscale='Portland')
)
data = [trace1]
layout = go.Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
fig = go.Figure(data=data, layout=layout)
return fig
我会接受这样的答案,因为没有其他人,但Plotly应该很喜欢在包括绘制3D线条更轻松的方式。像matplotlib的LineCollection会是理想的。 – ap21
@ ap21:我同意,加入'无'是相当危险的。我看到你在剧情论坛上要求这个功能,希望他们能听到你的声音! –