在3d散点图中连续绘制的色阶

时间:2020-01-31 23:03:12

标签: plotly

我需要在情节上做两件事,它们都与颜色缩放有关。

1)我有一个分散在3d上的时间序列

fig = go.Figure(data=go.Scatter(y=dy[roi_index],mode='markers',marker=dict(color=np.random.randn(8000),colorscale='Viridis',showscale=True,size=2)))
fig.show()

enter image description here

我想随着时间的增加对该颜色系列进行连续的色标处理。因此,没有点具有相同的颜色,因为没有点具有相同的时间值,并且颜色随着我们的前进而变化。

2)我希望能够记住这些颜色,并将这些点集映射到3d中时,我需要查看时间序列中这些点的颜色。

fig = go.Figure(data=[go.Scatter3d(x=SW_M_tau_traces[roi_index][0], y=SW_M_tau_traces[roi_index][1], z=SW_M_tau_traces[roi_index][2],mode='markers',marker=dict(size=1,color=,
colorscale="Viridis"))])
fig.show()


enter image description here

这就是我要说的: enter image description here

1 个答案:

答案 0 :(得分:1)

是的,您可以在2d和3d中都这样做:

import plotly.graph_objects as go
import numpy as np

# Helix equation
t = np.linspace(0, 10, 50)
x, y, z = np.cos(t), np.sin(t), t

fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z, mode='markers', 
                                   marker_color=z, marker_colorscale='Viridis')])
fig.show()

fig = go.Figure(data=[go.Scatter(x=z, y=y, mode='markers', 
                                   marker_color=z, marker_colorscale='Viridis')])
fig.show()

enter image description here

enter image description here