#create dataframe of reduced embeddings and clusters df = pd.DataFrame(reduced_embeddings, columns = ['x', 'y']) df['Cluster'] = [str(c) for c in clusters] #split between clusters and outliers to_plot = df.loc[df.Cluster != '-1', :] outliers = df.loc[df.Cluster == '-1', :] #plot clusters plt.scatter(outliers.x, outliers.y, alpha = 0.05, s = 2, c = 'grey') plt.scatter(to_plot.x, to_plot.y, alpha = 0.6, s = 2, c = to_plot.Cluster.astype(int), cmap = 'tab20b') plt.axis('off')