Hello together,
I have a question regarding a procedure.
I want to use a DBSCAN multidimensional scatterplot that I created in Matplotlib but i cant convert or rebuild it like the following code in plotly…
I want to use it in my dashboard in the Dash app.
My first approach was to convert the plot from Matplotlib to Plotly, but I can’t get this to work despite all the examples.
Does anyone know how I could display this plot in Plotly?
unique_labels = are the labels which im getting from my DBSCAN Cluster algorithmus, they tell me Cluster 0 , 1 or 5
In my Case i want to plot my whole dataframe ( so every dimension), which i reduced with a pca to a numpy array to get an 2D plot instead of 10 Dimensions…
db = DBSCAN(eps=epsilon, min_samples=3).fit(X_scale)
core_samples_mask = np.zeros_like(db.labels_, dtype=bool)
core_samples_mask[db.core_sample_indices_] = True
labels = db.labels_
unique_labels = set(labels)
colors = [plt.cm.Spectral(each) for each in np.linspace(0, 1, len(unique_labels))]
fig= plt.figure(figsize=(15, 15))
for k, col in zip(unique_labels, colors):
if k == -1:
# Black used for noise.
col = [0, 0, 0, 1]
class_member_mask = (labels == k)
xy = digits_pca[class_member_mask & core_samples_mask]
plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col), markeredgecolor='k', markersize=8)
xy = digits_pca[class_member_mask & ~core_samples_mask]
plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col), markeredgecolor='k', markersize=4)
plt.title('Estimated number of clusters: %d' % n_clusters_)
plt.show()
Furthermore I found a function to convert Matplotlib plots to Plotly plots, but it doesn’t work anymore or?
My next approach would be to save the plot as HTML and then include it in my dashboard.
But These seems like a complicated workaorund and feels not like a solution.
So im pretty new to plotly and maybe its just because of my proramming skills… but after several hours of trying i tought i better ask for help…
Thanks for response.