def plot_3d_clustering(X_red, labels, title=None):
component0 = X_red[:, 0]
component1 = X_red[:, 1]
component2 = X_red[:, 2]
indices = list(range(X_red.shape[0]))
labels = list (map(lambda x: "label:" + str(y[x]) + ", id:" + str(x),indices))
fig = go.Figure(data=[go.Scatter3d(
x=component0,
y=component1,
z=component2,
mode='markers',
marker=dict(
size=10,
color=y, # set color to an array/list of desired values
colorscale='Rainbow', # choose a colorscale
opacity=1,
line_width=1,
),
text = labels
)])
# tight layout
fig.update_layout(margin=dict(l=50,r=50,b=50,t=50),width=520,height=520)
fig.layout.template = 'plotly_dark'
fig.show()