Following the suggestion HERE I have tried the following code to create a Scatter3D plot with plotly in a jupyter notebook so each marker is colored individually, like you can do with matplotlib and something like
plt.scatter(x,y, c=z)
Here is the code:
cmap = matplotlib.colormaps['brg']
param = "elevation_deg"
min_value = min(vector)
max_value = max(vector)
range_ = max_value - min_value
colors = []
for value in vector:
rgba = cmap((value-min_value)/range_)
colors.append(f"rgb({int(255*rgba[0])},{int(255*rgba[1])},{int(255*rgba[2])})")
# Configure the trace.
trace = go.Scatter3d(
x=x,
y=y,
z=z,
mode='markers',
marker=dict(colors, size=10)
)
But I get the error
ValueError: dictionary update sequence element #0 has length 13; 2 is required
I also had a look at the documentation for Scatter3D, but I am totally lost in this page, it is totally confusing.
So maybe there is a more way way to do so? And also how to plot the colorbar, as you can do with matplotlib with plt.colorbar()
?
Try this one. It is working for me.