如何在Plotly 3D散点图上改变每个点的不透明度

时间:2019-08-20 14:09:24

标签: python plot 3d plotly

我正在用Plotly绘制一些激光雷达数据。数据由一个numpy数组组成,该数组包含x,y和z坐标以及每个点的强度(从0到255)。我可以绘制x,y和z坐标,但我想知道是否有可能改变基于强度值的每个点的不透明度?

如果没有,我猜可以改变颜色吗?

下面是我正在使用的代码:

x = readings_array[:, 0]
y = readings_array[:, 1]
z = readings_array[:, 2]
intensity = readings_array[:, 3]

# Configure Plotly to be rendered inline in the notebook.
plotly.offline.init_notebook_mode()

# Configure the trace.
trace = go.Scatter3d(x=x, y=y, z=z, mode='markers', marker={'size': 1,
                                                          'opacity': 0.8})


#creates a red dot to show the origin (I'm assuming the origin is where the lidar is located)
lidar=(go.Scatter3d(x=[0], y=[0], z=[0], marker={'size': 5,
                                                'opacity': 0}))

# Configure the layout.
layout = go.Layout(margin={'l': 0, 'r': 0, 'b': 0, 't': 0})

data = [trace, lidar]

plot_figure = go.Figure(data=data, layout=layout)

# Render the plot.
plotly.offline.iplot(plot_figure)

我尝试将opacity设置为:

opacity: float(intensity/255)

这似乎是实现它的最合乎逻辑的方式,但是它不起作用,因为它需要一个size-1数组(因此仅一个值)。

我想到的另一种方法是创建一个循环遍历所有点的循环,并逐个绘制每个点,但是有10,000个数据点,这似乎效率很低它!

0 个答案:

没有答案
相关问题