Colour points classes of points in scatter

I want to make a scatter plot of some data where I colour the point according to a class/familiy. In vanilla matplotlib I can do this with

hue_list=[colours[k] for k in familiy if k in colours]
ax.scatter(x, y, z, c=hue_list)

using the c kwarg to give a list of the colours for each point. How can I achieve a similar result in plotly?

Hi @Rhys, you can pass the hue_list as the scatter.marker.color property. Something like

import plotly.graph_objs as go
fig = go.Figure()
x = ...
y = ...
hue = ...
fig.add_scatter(mode='markers', x=x, y=y, marker={'color': hue))

Or for 3D

fig.add_scatter3d(mode='markers', x=x, y=y, z=z, marker={'color': hue))

Hope that helps!