我正在学习如何使用他们的示例和我自己的数据在 Plotly 上绘制 3D 散点图。样品在这里
我可以绘制散点图(它看起来很酷),但我无法让不同的数据系列点显示为单独的颜色。
import plotly #load plotly for plotting
import plotly.plotly as py
from plotly import tools
from plotly.graph_objs import * #all the types of plots that we will plot here
plotly.offline.init_notebook_mode() # run at the start of every ipython notebook
trace1 = Scatter3d(
x = res,
y = lc,
z = spent,
mode='markers',
marker=dict(
size=12,
color=["z","y","x"], # set color to an array/list of desired values
colorscale='Viridis', # choose a colorscale
opacity=0.8
)
)
data = [trace1]
layout = Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
fig = Figure(data=data, layout=layout)
plotly.offline.iplot(fig, filename='3d-scatter-colorscale')
Run Code Online (Sandbox Code Playgroud)
我尝试过使用其他单独来源的示例,例如 Cambridge Spark,但我只是没有经验来弄清楚如何使其工作。
我确信这是一些简单的事情,我错过了但看不到它。
我应该以我的系列之一作为标记点。在本例中,我使用花费而不是 x、y、z 列表
import plotly #load plotly for plotting
import plotly.plotly as py
from plotly import tools
from plotly.graph_objs import * #all the types of plots that we will plot here
plotly.offline.init_notebook_mode() # run at the start of every ipython notebook
trace1 = Scatter3d(
x = res,
y = lc,
z = spent,
mode='markers',
marker=dict(
size=12,
color=spent, # set color to an array/list of desired values
colorscale='Viridis', # choose a colorscale
opacity=0.8
)
)
data = [trace1]
layout = Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
fig = Figure(data=data, layout=layout)
plotly.offline.iplot(fig, filename='3d-scatter-colorscale')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11997 次 |
最近记录: |